Question: The following algorithm uses a divide - and - conquer technique to find the maximum element in an array of size n . The initial
The following algorithm uses a divideandconquer technique to find the maximum element in an array of size n The initial call to this recursive function is maxarrayname n dtype Findmaxdtype A int i int ni is the starting index, and n is the number of elements. dtype M ax M ax; if n return Ai; M ax Findmax A i bnc; Find max of the first half M ax Findmax A i bnc dne; Find max of the second half if M ax M ax return M ax; else return M ax; Let fn be the worstcase number of key comparisons for finding the max of n elements. a Assuming n is a power of write a recurrence relation for fn Find the solution by each of the following methods. i Apply the repeated substitution method. ii Apply induction to prove that fn An B and find the constants A and Bb Now consider the general case where n is any integer. Write a recurrence for fn Use induction to prove that the solution is fn n
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
