Question: Problem 2. Consider the algorithms from class for finding the maximum contiguous sum. Assume that it takes time r to execute the instruction SES +
![SES + A[x] (a) i. Write a sum for exactly how much](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66eec4f9eac1a_02566eec4f941dde.jpg)

Problem 2. Consider the algorithms from class for finding the maximum contiguous sum. Assume that it takes time r to execute the instruction SES + A[x] (a) i. Write a sum for exactly how much time the third algorithm (the linear algorithm) takes executing additions involving elements from the array A? Do not justify. ii. Simplify your sum. Do not justify. (b) i. Write a sum for exactly how much time the second algorithm (the quadratic algorithm) takes executing additions involving elements from the array A? Do not justify. ii. Simplify your sum. Show your work. M 0; for i = 1 to n do for j = i to n do SE 0; for k = i to j do SA S + A[k]; end for M max(M,S); end for end for M = 0; for i = 1 to n do SE 0; for j = i to n do SE S + A[j]; M + max(M,S); end for end for M = 0; St 0; for i = 1 to n do st max (S+A[i],0); M + max(M,S); end for
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
