Average Case and Distributional Analysis of Dual-Pivot Quicksort

Wild, Sebastian ORCID: 0000-0002-6061-9177, Nebel, Markus E and Neininger, Ralph
(2015) Average Case and Distributional Analysis of Dual-Pivot Quicksort. ACM Transactions on Algorithms, 11 (3). 3-.

[img] Text
wild-nebel-neininger-2015.pdf - Author Accepted Manuscript

Download (482kB) | Preview


In 2009, Oracle replaced the long-serving sorting algorithm in its Java 7 runtime library by a new dual-pivot Quicksort variant due to Vladimir Yaroslavskiy. The decision was based on the strikingly good performance of Yaroslavskiy's implementation in running time experiments. At that time, no precise investigations of the algorithm were available to explain its superior performance—on the contrary: previous theoretical studies of other dual-pivot Quicksort variants even discouraged the use of two pivots. In 2012, two of the authors gave an average case analysis of a simplified version of Yaroslavskiy's algorithm, proving that savings in the number of comparisons are possible. However, Yaroslavskiy's algorithm needs more swaps, which renders the analysis inconclusive. To force the issue, we herein extend our analysis to the fully detailed style of Knuth: we determine the exact number of executed Java Bytecode instructions. Surprisingly, Yaroslavskiy's algorithm needs sightly more Bytecode instructions than a simple implementation of classic Quicksort—contradicting observed running times. As in Oracle's library implementation, we incorporate the use of Insertionsort on small subproblems and show that it indeed speeds up Yaroslavskiy's Quicksort in terms of Bytecodes; but even with optimal Insertionsort thresholds, the new Quicksort variant needs slightly more Bytecode instructions on average. Finally, we show that the (suitably normalized) costs of Yaroslavskiy's algorithm converge to a random variable whose distribution is characterized by a fixed-point equation. From that, we compute variances of costs and show that for large n, costs are concentrated around their mean.

Item Type: Article
Additional Information: v3 is content-wise identical to TALG version
Uncontrolled Keywords: Analysis of algorithms, dual-pivot Quicksort, limiting distributions
Depositing User: Symplectic Admin
Date Deposited: 21 Oct 2019 15:29
Last Modified: 19 Jan 2023 00:21
DOI: 10.1145/2629340
Related URLs:
URI: https://livrepository.liverpool.ac.uk/id/eprint/3058951