Question: Answer the following questions: a. How does this algorithm find the max? b. What are the legal inputs? c. What is the base case? d.

Answer the following questions:
a. How does this algorithm find the max?
b. What are the legal inputs?
c. What is the base case?
d. Draw the recursion tree showing inputs and outputs if the input is the array [1,2,3,4,5]
e. Why is this an example of tail recursion?
f. how would you change to make into iterative problem instead of recursive
Find-max-1(A:array [....] of number) returns number k: number 1 if i==j then return A[i] 2 k= find-max(A:array [i+1...j]) 3 if k>A[i] then return k else return A[i] Find-max-1(A:array [....] of number) returns number k: number 1 if i==j then return A[i] 2 k= find-max(A:array [i+1...j]) 3 if k>A[i] then return k else return A[i]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
