Question: Assume that are given a black-box (i.e., you do not have the source code) procedure MEDIAN that takes as parameters an array A and subarray
Assume that are given a "black-box" (i.e., you do not have the source code) procedure MEDIAN that takes as parameters an array A and subarray indices p and r, and returns the value of the median element of A[p . . r] in O(n) time in the worst case. Give a simple, linear-time algorithm that uses this procedure MEDIAN to find the ith smallest element. Write the recurrence relation for you algorithm and show the solution is linear growth.
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
