0

What is the worst case time complexity of median of medians quicksort ( pivot is determined by the median of medians which take O(n) time to find )?

Naman Jain
  • 63
  • 9

1 Answers1

2

According to Wiki,

The approximate median-selection algorithm can also be used as a pivot strategy in quicksort, yielding an optimal algorithm, with worst-case complexity O(n log n).

This is because the median of medians algorithm prevents the bad partitioning that would occur in naive quicksort on an already sorted array.

Peter Olson
  • 121,487
  • 47
  • 188
  • 235