AI 中文总结
本文提出定向归并排序及其改进版,通过跳过检查与动态归并方向调整,在保持最优比较次数界限的同时,将栈空间从 $O(\lg n)$ 降至 $O(1)$,还可适应递减游程。
AI 中文摘要
本文提出一种稳定的归并排序变体“定向归并排序”,用于对含 $n$ 个元素的数组排序时,比较次数不超过 $nH+3n$,移动次数为 $1.5nH+O(n)$,其中 $H$ 是输入序列基于游程的熵,在游程自适应排序中与现有最优算法性能相当。然而该算法极其简约:仅利用跳过检查,即当两个子序列均已有序时跳过归并步骤,以及基于子数组状态动态改变归并方向。由于避免了动态游程扫描,所有归并步骤保持静态且可由 $n$ 推导,因此“定向归并排序$^{++}$”可将栈空间(即归并缓冲区之外的空间)减少至 $O(1)$ 个单词,优于前代算法的 $O(\text{lg}\\ n)$ 个单词。重要的是,定向归并排序仅适应非递减游程,定向归并排序$^{++}$还为严格递减游程应用一组并行规则,使算法在保持原有比较次数界限的同时,也能适应递减游程。
英文摘要
In this paper, we present a stable mergesort variant, "directional mergesort", that to sort an array of $n$ elements makes no more than $nH+3n$ comparisons and $1.5nH+O(n)$ moves where $H$ is the run-based entropy of the input sequence, matching the best existing algorithms in run-adaptive sorting. However, our algorithm is surprisingly minimalistic: it leverages only skip checks, i.e., bypassing the merge step when both halves are already in order, and dynamically changing the direction of merging based on the state of the subarrays. As dynamic run scanning is avoided, all merge steps remain static and derivable from $n$, enabling a reduction to $O(1)$ words of stack space (i.e. space usage excluding the merge buffer) in "directional mergesort$^{++}$", thus improving over the predecessors' $O(\lg n)$ words. Importantly, as directional mergesort adapts only to non-decreasing runs, directional mergesort$^{++}$ also applies a parallel set of rules for (strictly) decreasing runs, allowing the algorithm to also adapt to decreasing runs whilst retaining the original comparison bounds.
Comments21 pages, 15 pages main text, 4 pages appendix, 2 figures