HackerPapers

arXiv:1303.5217cs.DS

Optimal Partitioning for Dual-Pivot Quicksort

Martin Aumüller, Martin Dietzfelbinger

Abstract

Dual-pivot quicksort refers to variants of classical quicksort where in the partitioning step two pivots are used to split the input into three segments. This can be done in different ways, giving rise to different algorithms. Recently, a dual-pivot algorithm proposed by Yaroslavskiy received much attention, because a variant of it replaced the well-engineered quicksort algorithm in Sun's Java 7 runtime library. Nebel and Wild (ESA 2012) analyzed this algorithm and showed that on average it uses 1.9n ln n + O(n) comparisons to sort an input of size n, beating standard quicksort, which uses 2n ln n + O(n) comparisons. We introduce a model that captures all dual-pivot algorithms, give a unified analysis, and identify new dual-pivot algorithms that minimize the average number of key comparisons among all possible algorithms up to a linear term. This minimum is 1.8n ln n + O(n). For the case that the pivots are chosen from a small sample, we include a comparison of dual-pivot quicksort and classical quicksort. Specifically, we show that dual-pivot quicksort benefits from a skewed choice of pivots. We experimentally evaluate our algorithms and compare them to Yaroslavskiy's algorithm and the recently described three-pivot quicksort algorithm of Kushagra et al. (ALENEX 2014).

arXiv comments
Accepted for publication in ACM Transactions on Algorithms
Journal reference
DOI
Subjects
cs.DSData Structures and Algorithms

On Hacker News

Linked by 2 identifiable commenters in 2 comments across 2 threads, from Aug 2013 to Oct 2017. Found in 1 HN submission from Mar 2013 to Mar 2013. Open submission discussions.

Comments linking this paper, per year.

Discussed in comments2 threads

  1. Quicksort (1961) [pdf] 1 comment
    • Your article [1] isn't a real published article, and it doesn't have a proper analysis. For somebody who has actually done the work, and gotten it published, see https://arxiv.org/pdf/1303.5217.pdf

      thomasahleView on HNParent context

    • I don't know what happened, but I got to level 21 somehow. :) This is cool and handy for lecturers explaining sorting/searching. In practice: merge, insertion and dual pivot [1] /single pivot quick(er)sort [2] are the usual tools in the toolbox, that like everything, depend on…

      ballardView on HNParent context

Submitted to Hacker News

Connected through shared HN threads, not inferred similarity or a recommendation.