# If the median median algorithm doesn't change the complex complexity of quicksort, why use it?

1 answer

As it has the best worst time complexity .

The approximate median selection algorithm can also be used as a summary strategy in quicksort, which gives the optimal algorithm with the worst complexity O (n log n). While this approach optimizes well enough, it usually outperforms sampling random rotations, which has an average linear time for selecting and an average log linear time for sorting, and avoids the overhead of computing a hinge. The median of medians is used in the hybrid introselect algorithm as a fallback to provide the worst linear performance: introselect starts with quickselect to get a good average performance and then falls back to the median median if progress is too slow.

+3

source to share