Problem Detail: 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?
Asked By : balajeerc
Answered By : D.W.
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: Jon L. Bentley, M. Douglas McIlroy, “Engineering a Sort Function“. Software Practice and Experience, 23(11):1249-1265, Nov 1993. (This paper is cited in the Wikipedia article I mentioned above.) I’m not familiar with the “uniform shuffle” pivot selection method. It sounds equivalent to choosing a random element and using that as the pivot.
Best Answer from StackOverflow
Question Source : http://cs.stackexchange.com/questions/49009