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 number 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 that 1+2+4+...+2^p = 2^(p+1) − 1.