Question: Problem 1 Let S = ( s 1 , s 2 , cdots, s n ) be a sequence of n numbers. A contiguous subsequence

Problem 1
Let S=(s1,s2,cdots,sn) be a sequence of n numbers. A "contiguous subsequence" of S is a subsequence si,si+1,cdots,sj
(for some 1ijn), which is made up of consecutive elements of S.(For example, if ),
then 16,-29,11 is a "contiguous subsequence", but 6,16,41 is not.) Given a sequence S, our objective is to find a contiguous
subsequence whose sum if maximized. (For example, if S=(6,16,-29,11,-4,41,11), such a contiguous subsequence would
be 11,-4,41,11, whose sum is 59.)
Our "Maximum-Sum Contiguous Subsequence Problem" is defined as follows:
Input: A sequence of numbers S=(s1,s2,cdots,sn).
Output: A contiguous subsequence of S whose sum is maximized.
Your task: Design an algorithm of time complexity O(n) for the above problem. (Remember: as we emphasized in class,
whenever you design an algorithm, you need to: (1) explain the main idea of the algorithm, (2) present its pseudo-code, (3)
prove its correctness, (4) analyze its time complexity. For dynamic programming, (1) and (3) can often be the same.)
(Hint: For each jin{1,2,cdots,n}, consider contiguous subsequences ending exactly at position j.)
 Problem 1 Let S=(s1,s2,cdots,sn) be a sequence of n numbers. A

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!