Question: To find the median element in an array select a random element in the data to use as pivot and partiriton the data into sets
To find the median element in an array select a random element in the data to use as pivot and partiriton the data into sets of elements greater and lesser than the pivot. From the size of these sets we know the position of the pivot in the total order and whether the median lies to the left or the right of the pivot. It takes O(logn) iterations with the cost of each iteration being roughly half of the previous one. Prove that it converges to linear time algorithm.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
