Journal of Algorithms - Analysis of algorithms
Adaptive sampling for quickselect
SODA '04 Proceedings of the fifteenth annual ACM-SIAM symposium on Discrete algorithms
On Floyd and Rivest's SELECT algorithm
Theoretical Computer Science
Efficient sample sort and the average case analysis or PEsort
Theoretical Computer Science
How branch mispredictions affect quicksort
ESA'06 Proceedings of the 14th conference on Annual European Symposium - Volume 14
A data-driven multidimensional indexing method for datamining in astrophysical databases
EURASIP Journal on Applied Signal Processing
On the adaptiveness of Quicksort
Journal of Experimental Algorithmics (JEA)
Optimal splitters for database partitioning with size bounds
Proceedings of the 12th International Conference on Database Theory
Adaptive sampling strategies for quickselects
ACM Transactions on Algorithms (TALG)
ICALP'10 Proceedings of the 37th international colloquium conference on Automata, languages and programming
Hi-index | 0.01 |
It is well known that the performance of quicksort can be improved by selecting the median of a sample of elements as the pivot of each partitioning stage. For large samples the partitions are better, but the amount of additional comparisons and exchanges to find the median of the sample also increases. We show in this paper that the optimal sample size to minimize the average total cost of quicksort, as a function of the size n of the current subarray size, is $a\cdot \sqrt{n} + o(\sqrt{n}\,)$. We give a closed expression for a, which depends on the selection algorithm and the costs of elementary comparisons and exchanges. Moreover, we show that selecting the medians of the samples as pivots is not the best strategy when exchanges are much more expensive than comparisons. We also apply the same ideas and techniques to the analysis of quickselect and get similar results.