Chapter 6: 1E (page 169)
A contiguous subsequence of a list is a subsequence made up of consecutive elements of . For instance, if is
then is a contiguous subsequence but is not. Give a linear-time algorithm for the following task:Input: A list of numbers .Output: The contiguous subsequence of maximum sum (a subsequence of length zero has sum zero).For the preceding example, the answer would be , with a sum of 55. (Hint: For each , consider contiguous subsequences ending exactly at position j.)
Short Answer
The algorithm to find contiguous subsequence of maximum sum is implemented using dynamic programming in linear time.