Question: The median-of-medians algorithm for selecting the kth smallest element in an array A[1, n] is as follows. Divide A into n/5 subarrays, each of

The median-of-medians algorithm for selecting the kth smallest element in an array A[1, n] is as follows. Divide A into n/5 subarrays, each of size 5, then get the medians of these subarrays and find the median of these medians (call it x). Using x as the pivot, we partition the elements in A into two subarrays and continue the recurrence in only one of the subarrays. This leads to a linear time algorithm. Instead of 5, if we choose 7, what will be the resulting time complexity? Also, analyze the complexity when 3 is chosen instead of 5.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
