Question: Suppose you want to find the minimum and maximum elements of an unsorted array of length n . One way is to scan through the

Suppose you want to find the minimum and maximum elements of an unsorted array of length n. One way is to scan through the array once to find the maximum (which requires n 1 comparisons between values), and scan through it a second time to find the minimum (which also requires n 2 comparisons between values if you eliminate the maximum element first), for a total of 2n 3 comparisons. You can do this more efficiently with divide-and-conquer. Design a divide-and-conquer algorithm to find the minimum and maximum elements of an unsorted array, which performs at most (3n/2)2 comparisons between elements in total.
(a) Present a recursive divide-and-conquer algorithm for solving this problem.
(b) Give a recurrence relation, including base case(s), that describes the num- ber of comparisons in each call to your recursive function. Your recurrence relation should be a function of n, where n is the size of the array.
(c) Prove that the value of your recurrence is at most (3n/2)2 for all n >0.
For simplicity, you can assume that n is a power of 2. Make use of the fact that1+2+4+...+2p =2p+11

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!