Search for question
Question

4. [10 points] Given an array of real numbers A[1...n], we want to compute and return the prefix sum array P[1...n] such that P[i] = A[1] + A[2] + A[3] + ... + A[i]. PREFIXSUM-NONRECURSIVE(A[1...n]) (i) Design a O(n) non-recursive algorithm to solve the problem. (ii) Design a O(n) recursive algorithm the problem. PREFIXSUM-RECURSIVE(A[1...n]) to solve

Fig: 1