Question: Riddle (A)// A1..n] is array of size n Problem 4 (15 points) (3 points) Let A be an array of n integers 2 Set i-1
Riddle (A)// A1..n] is array of size n Problem 4 (15 points) (3 points) Let A be an array of n integers 2 Set i-1 which can be positive or negative, what I 4 set t 5 whileisn 6 set t = t + A[j] does this algorithm do? Justify your answer ift>m (3 points) Analyze its running time. Set m- t 9 points) Come up with a better algorithm9 if j for the same problem. For example, if the original algorithm is O(n), then your algorithm must be better, like O(nz) or O(n), | increase i by 1 Set j -i Set t = 0 12 13 14 else Increase j by 1 return m etc
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
