Question: Problem 1. (12 marks) Consider the following program: procedure Foo(A, f.l) recondition: A [f . . . 1] is an array of integers, f, I

Problem 1. (12 marks) Consider the following program: procedure Foo(A, f.l) recondition: A [f . . . 1] is an array of integers, f, I are two naturals-1 with f if (f = 1) then 1. return Al] else return max(Foo(A, f,m), Foo(A, m+1,1)) end if a. (4 marks) Suppose A = [7, 12, 8, 4, 4, 8, 10, 12.6 and consider the call Foo(A, 1,9). Show all recursive calls by drawing a tree, and for each call, indicate what is returned. b. (4 marks) Give a formal statement about what Foo does, and prove it c. (4 marks) Write a recurrence relation to describe the number of max-operations run by Foo in terms of the size of array A, and using the master theorem, give a bound on the complexity of this program
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
