arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 1412.0193cs.DSmath.PR
收藏

双枢轴快速排序中枢轴抽样的分析

Analysis of Pivot Sampling in Dual-Pivot Quicksort

Sebastian Wild, Markus E. Nebel, Conrado Martínez

摘要:

Vladimir Yaroslavskiy的新双枢轴快速排序-从版本7开始在Oracle的Java运行时库中使用-具有有趣的不对称性。他们使这个算法的一个基本变体比经典的单枢轴快速排序使用更少的比较。在本文中,我们将分析的情况下,两个枢轴被选为固定顺序统计量的随机样本。令人惊讶的是,双枢轴快速排序需要比经典快速排序的相应版本更多的比较,所以很明显,计数比较不足以解释在实践中观察到的Yaroslavskiy算法的运行时间优势。因此,我们采取了一个更全面的方法,并给出了准确的前导项的平均交换次数,执行的Java字节码指令的数量和扫描的元素的数量,一个新的简单的成本措施,近似I/O成本的存储层次结构。我们为每个成本度量确定最优顺序统计量。事实证明,Yaroslavskiy算法中的不对称性使具有系统偏斜的枢轴比对称选择更有效。此外,我们终于有一个令人信服的解释,在实践中的成功Yaroslavskiy的算法:与相应版本的经典单枢轴快速排序,双枢轴快速排序需要显着减少的I/O,无论有没有枢轴采样。

英文摘要:

The new dual-pivot Quicksort by Vladimir Yaroslavskiy - used in Oracle's Java runtime library since version 7 - features intriguing asymmetries. They make a basic variant of this algorithm use less comparisons than classic single-pivot Quicksort. In this paper, we extend the analysis to the case where the two pivots are chosen as fixed order statistics of a random sample. Surprisingly, dual-pivot Quicksort then needs more comparisons than a corresponding version of classic Quicksort, so it is clear that counting comparisons is not sufficient to explain the running time advantages observed for Yaroslavskiy's algorithm in practice. Consequently, we take a more holistic approach and give also the precise leading term of the average number of swaps, the number of executed Java Bytecode instructions and the number of scanned elements, a new simple cost measure that approximates I/O costs in the memory hierarchy. We determine optimal order statistics for each of the cost measures. It turns out that the asymmetries in Yaroslavskiy's algorithm render pivots with a systematic skew more efficient than the symmetric choice. Moreover, we finally have a convincing explanation for the success of Yaroslavskiy's algorithm in practice: Compared with corresponding versions of classic single-pivot Quicksort, dual-pivot Quicksort needs significantly less I/Os, both with and without pivot sampling.

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

↑