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 comparisons between values and scan through it a second time to find the minimum which also requires n comparisons between values if you eliminate the maximum element first for a total of n comparisons. You can do this more efficiently with divideandconquer. Design a divideandconquer algorithm to find the minimum and maximum elements of an unsorted array, which performs at most n comparisons between elements in total.
a Present a recursive divideandconquer algorithm for solving this problem.
b Give a recurrence relation, including base cases 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 n for all n
For simplicity, you can assume that n is a power of Make use of the fact thatp p
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
