What does this definition of contiguous subsequences mean?
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
then{5, 15, -30, 10, -5, 40, 10}开发者_开发问答
15, -30, 10
is a contiguous subsequence.
What makes 15, -30, 10
a contiguous subsequence?
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!
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.
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).
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).
Uhm, maybe because they are consecutive as per your definition?
They are elements of your original array and they are all continous.
Contiguous elements are consecutive elements.
Respectively list some elements from array S without skipping any element from the middle of that list.
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.
15, -30, 10
is not a contiguous sequence.
The answer from user brad would indicate that the sequence of numbers you referenced is not contiguous. You can also validate this by running code from geeksforgeeks.org.
精彩评论