What does this definition of contiguous subsequences mean?

烈酒焚心 提交于 2019-11-29 17:10:45

问题


I don't understand the following definition of a contiguous subsequence:

A contiguous subsequence of a list S is a subsequence made up of consecutive elements of S.

If S is {5, 15, -30, 10, -5, 40, 10}
then 15, -30, 10 is a contiguous subsequence.

What makes 15, -30, 10 a contiguous subsequence?


回答1:


The form a subset that are next to each other within the set.

con·tig·u·ous/kənˈtigyo͞oəs/Adjective
1. Sharing a common border; touching.
2. Next or together in sequence. 



回答2:


A contiguous subsequence of a list S is a subsequence made up of consecutive elements of S.




回答3:


Lets say you have some elements in a subsequence,

then it will be called contiguous iff the elements taken in order are consecutive in original set.

E.g,

Sequence=2,3,abc,5.6,4,abhishek;

Subsequence=5.6,2,abhishek;

Contiguous Subsequence=3,abc,5.6 or 5.6,4,abhishek or abc,5.6.

Remember, The sequence itself is always a contiguous subsequence.

Hope it makes the concept clear!




回答4:


This is not directly programming related but 15, 30, -15 is a contiguous subsequence because you can find them in the same order inside the given list (without any holes between the elements of course).




回答5:


Uhm, maybe because they are consecutive as per your definition?




回答6:


They are elements of your original array and they are all continous.




回答7:


Respectively list some elements from array S without skipping any element from the middle of that list.




回答8:


In the series (5,15,-30,10,-5,40,10) 5,15,-30 are one after another so they are contiguous but 5,15,40 are not contiguous because we skipped -30,10, and -5 and took 40. In Dasgupta's book, we need to find a sub series of the main series which makes the largest possible sum. Which in this case is 10,-5,40,10. Which is (10-5+40+10=55).




回答9:


Contiguous elements are consecutive elements.




回答10:


A subsequence can be formed from any subset of items from the original subsequence, so from above {5,10,40} is a valid subsequence. A contiguous subsequence is more restricted, it requires the elements to be consecutive elements from the list, NOT that the values are consecutive but that the positions of the elements taken from the original are consecutive. I suspect that this distinction was the OPs point of confusion.



来源:https://stackoverflow.com/questions/3988575/what-does-this-definition-of-contiguous-subsequences-mean

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!