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

Given the hard lower bound of the sorting algorithm, the average complexity of the Omega case (n * lg (n)), when / why did you decide to spend time implementing this selection algorithm with quicksort and not just a random rod or just simple (n / 2) th position in the array?


source to share

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.



All Articles