What does this definition of contiguous subsequences mean?

Viewed 32776

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?

10 Answers

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).

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

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.

Related