0

In several posts (e.g., https://cs.stackexchange.com/questions/125995/median-of-medians-proof-for-time-complexity) and articles on Google, I've seen the following time complexity recurrence written for the median of medians:

T(n) <= T(n/5) + T(7n / 10) + O(n)

But I am confused as this recurrence seems to consider MoM as embedded into quick select and is therefore the recurrence formula for quick select to find an exact median while using MoM for finding an approximate pivot.

If we're simply finding to find an approximate median using MoM, then what is the recurrence? Would it just be

T(n) <= T(n/5) + O(n) ?

user5965026
  • 465
  • 5
  • 16

1 Answers1

0

The median-of-medians algorithm recursively calls the full quickselect at each level.

If you use "plain" m-o-m instead of quickselect to get your pivot for quicksort, you are only simplifying the top level quickselect. All the lower-level calls remain, and so the complexity of the whole operation does not change.

Matt Timmermans
  • 53,709
  • 3
  • 46
  • 87