Severity: Warning
Message: fopen(/home/answnniz/public_html/system/sessions/ci_sessionf67e0eef7090a636c0d93ae25c06fce1b92c3083): failed to open stream: Disk quota exceeded
Filename: drivers/Session_files_driver.php
Line Number: 176
Backtrace:
File: /home/answnniz/public_html/index.php
Line: 315
Function: require_once
Severity: Warning
Message: session_start(): Failed to read session data: user (path: /home/answnniz/public_html/system/sessions)
Filename: Session/Session.php
Line Number: 143
Backtrace:
File: /home/answnniz/public_html/index.php
Line: 315
Function: require_once
Problem 1 Let
S=(s_(1),s_(2),cdots,s_(n))be a sequence of
nnumbers. A "contiguous subsequence" of
Sis a subsequence
s_(i),s_(i+1),cdots,s_(j)(for some
1<=i<=j<=n), which is made up of consecutive elements of
S. (For example, if ), then
16,-29,11is a "contiguous subsequence", but
6,16,41is 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=(s_(1),s_(2),cdots,s_(n)). Output: A contiguous subsequence of
Swhose 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.)
