arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1303.5217cs.DS
收藏

双枢轴快速排序的最优划分

Optimal Partitioning for Dual-Pivot Quicksort

Martin Aumüller, Martin Dietzfelbinger

摘要:

双枢轴快速排序是指经典快速排序的变体,其中在分区步骤中使用两个枢轴将输入分成三个部分。这可以以不同的方式完成,从而产生不同的算法。最近,由Yaroslavskiy提出的双主元算法受到了广泛关注,因为它的一个变体取代了Sun的Java 7运行时库中设计良好的快速排序算法。Nebel和Wild(ESA 2012)分析了这个算法,并表明它平均使用1.9n ln n + O(n)次比较来对大小为n的输入进行排序,击败了标准的快速排序,它使用2n ln n + O(n)次比较。我们引入了一个模型,捕获所有的双枢轴算法,给出了一个统一的分析,并确定新的双枢轴算法,最大限度地减少所有可能的算法之间的关键比较的平均数的线性项。这个最小值是1.8nlnn + O(n)。对于从小样本中选择枢轴的情况,我们包括双枢轴快速排序和经典快速排序的比较。具体来说,我们表明,双枢轴快速排序的好处从一个倾斜的选择枢轴。我们通过实验评估了我们的算法,并将其与Yaroslavskiy的算法和Kushagra等人最近描述的三枢轴快速排序算法(ALENEX 2014)进行了比较。

英文摘要:

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).

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑