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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!