A numerical analysis of Quicksort: How many cases are bad cases?
Guido Hartmann

TL;DR
This paper numerically analyzes the probability of Quicksort's worst-case scenarios, showing how different pivot selection methods influence the likelihood of bad cases and proposing a median-based approach with improved worst-case complexity.
Contribution
It introduces a detailed numerical method to estimate bad case probabilities for Quicksort and proposes a median-of-medians pivot selection method with a theoretical worst-case complexity of O(n^1.37).
Findings
Probability of bad cases varies greatly with pivot selection method.
For n=500, bad case probability ranges from 2.2*10^(-3) to 3.0*10^(-23).
Median-of-medians approach suggests worst-case complexity of O(n^1.37).
Abstract
We present numerical results for the probability of bad cases for Quicksort, i.e. cases of input data for which the sorting cost considerably exceeds that of the average. Dynamic programming was used to compute solutions of the recurrence for the frequency distributions of comparisons. From these solutions, probabilities of numbers of comparisons above certain thresholds relative to the average were extracted. Computations were done for array sizes up to n = 500 elements and for several methods to select the partitioning element, from a simple random selection to what we call "recursive median of three medians." We found that the probability strongly depends on the selection method: for n = 500 and a theshold 25% above the average number of comparisons it ranges from 2.2*10^(-3) to 3.0*10^(-23). A version of Quicksort based on the recursive median of medians approach is proposed, for…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsAlgorithms and Data Compression · Cellular Automata and Applications · graph theory and CDMA systems
