Question & Answer: Request solve the undermentioned problem on "Introduction to Alogrithms"…..

Request solve the undermentioned problem on “Introduction to Alogrithms”The maximum subsequence sum problem is defined as follows: If ai, a2, ..., an are in Z, find the maximum value Σkiai, for all i, j, 1 i <j < n. we assume that the answer is 0 if all the ai are negative or if the sum is empty. The following algorithm finds a solution to the problem. Here, we assume that as are stored in the array A. MaximuM-SUBSEQUENCE(A, MaxSum) 1 Sum ← 0, MaxSum ← 0 2 for i ← 1 to n 3 do Sum = Sum +A [i] if Sum MarSum then MaxStan ← Sum else if Sum<0 then Sum 。 Analyse the algorithm and find an upper bound for the run time of the above algorithm. (5)

The maximum subsequence sum problem is defined as follows: If a_1, a_2, . a_n are in Z, find the maximum value Sigma^j_k=i a_i, for all i, j, 1 lessthanorequalto i lessthanorequalto j lessthanorequalto n. We assume that the answer is 0 if all the a_i, are negative or if the sum is empty. The following algorithm finds a solution to the problem. Here, we assume that a_is are stored in the array A. MAXIMUM-SUBSEQUENCE(A, MaxSum) 1 Sum leftarrow 0, MaxSum leftarrow 0 2 for i leftarrow 1 to n 3 do 4 Sum = Sum + A [i] 5 if Sum > MaxSum 6 then MaxSum leftarrow Sum 7 else if Sum

Expert Answer

 

Still stressed from student homework?
Get quality assistance from academic writers!