# Quick Sort: Randomized Pivot vs Median of 3/'Ninther' Pivot vs Uniform Shuffle of Input

Is the jury still out on this or do we now know which of the above mentioned ways of randomizing Quick Sort is the most optimum as far as average case running time (averaged over all possible input arrays, with all permutations of the numbers being equally likely) is concerned?

Or perhaps, has a case been made for the assertion that a generalization is not possible?

• This would be clearer if you explained what "3/'Nther'" meant. – Rick Decker Nov 3 '15 at 2:15
• @RickDecker It's a particular partitioning + pivot selection strategy, iirc. – Raphael Nov 3 '15 at 6:41
• What do you mean by "most optimal"? (For one thing, "optimal" does not have a superlative, it is one.) Which cost measure do you want to use? See also here. – Raphael Nov 3 '15 at 6:43

The asymptotic expected running time of quicksort is $\Theta(n \log n)$: this is true for all three pivot methods you mention.
Wikipedia says that the expected number of comparisons is approximately $1.386 n \log n$ when using a random pivot, and approximately $1.188 n \log n$ when using median-of-three pivot. There's some experimental evidence that the number of comparisons might be about $1.094n \log n$ when using a ninther pivot for large arrays, median-of-three for medium-sized arrays, and single element for small arrays. See the following research paper:
• Why the expected depth is $O(\log N)$? – Mr. Newman Oct 7 '17 at 17:36