Modern comparison sorts like quicksort suffer from performance inconsistencies due to suboptimal pivot selection, leading to $(O(N^2))$ worst-case complexity, while in-place merge sort variants face challenges with data movement overhead. We introduce Wave Sort, a novel in-place sorting algorithm that addresses these limitations through a dynamic pivot selection strategy. Wave Sort iteratively expands a sorted region and selects pivots from this growing sorted portion to partition adjacent unsorted data. This approach ensures robust pivot selection irrespective of dataset size, guarantees a logarithmic recursion stack depth, and enables efficient in-place sorting. Our analysis shows a best comparison complexity of $(N-1)$, average comparison complexity close to $(\log_2(N)!)$, and worst-case comparison complexity bounded by $(O(N(\log(N))^2))$ with a small constant factor, which could be reduced to $(O(N\log(N)))$ with hybrid sorting. The algorithm can be easily expanded to be hybridized with other sorting algorithms. Experimental results demonstrate that Wave Sort requires significantly fewer comparisons than quicksort on average (approximately 24% less) and performs close to the theoretical minimum $(\log_2(N)!)$. Wave Sort offers a compelling alternative for applications demanding consistent, predictable, and in-place sorting performance.


翻译:现代比较排序算法(如快速排序)由于枢轴选择欠佳而存在性能不一致的问题,导致最坏情况复杂度为 $(O(N^2))$,而原地归并排序变体则面临数据移动开销的挑战。我们提出 Wave Sort,一种新颖的原位排序算法,通过动态枢轴选择策略解决了这些限制。Wave Sort 迭代地扩展已排序区域,并从这一不断增长的已排序部分中选择枢轴来划分相邻的未排序数据。这种方法确保了无论数据集大小如何都能进行稳健的枢轴选择,保证了递归栈深度的对数级,并实现了高效的原位排序。我们的分析表明,其最佳比较复杂度为 $(N-1)$,平均比较复杂度接近 $(\log_2(N)!)$,最坏情况比较复杂度受限于 $(O(N(\log(N))^2))$ 且常数因子较小,通过混合排序可进一步降低至 $(O(N\log(N)))$。该算法可以轻松扩展以与其他排序算法混合使用。实验结果表明,Wave Sort 平均所需的比较次数显著少于快速排序(约减少 24%),且性能接近理论最小值 $(\log_2(N)!)$。对于要求一致、可预测且原地排序性能的应用,Wave Sort 提供了一个引人注目的替代方案。

0
下载
关闭预览

相关内容

排序是计算机内经常进行的一种操作,其目的是将一组“无序”的记录序列调整为“有序”的记录序列。分内部排序和外部排序。若整个排序过程不需要访问外存便能完成,则称此类排序问题为内部排序。反之,若参加排序的记录数量很大,整个序列的排序过程不可能在内存中完成,则称此类排序问题为外部排序。内部排序的过程是一个逐步扩大记录的有序序列长度的过程。
《用于代码弱点识别的 LLVM 中间表示》CMU
专知会员服务
14+阅读 · 2022年12月12日
【CIKM2022】基于双向Transformers对比学习的序列推荐
专知会员服务
21+阅读 · 2022年8月10日
【NeurIPS 2021】类比进化算法:设计统一的序列模型
专知会员服务
16+阅读 · 2021年10月30日
专知会员服务
46+阅读 · 2020年10月22日
【NeurIPS2019】图变换网络:Graph Transformer Network
NAACL 2019 | 一种考虑缓和KL消失的简单VAE训练方法
PaperWeekly
20+阅读 · 2019年4月24日
CNN 反向传播算法推导
统计学习与视觉计算组
30+阅读 · 2017年12月29日
国家自然科学基金
2+阅读 · 2016年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Arxiv
0+阅读 · 1月1日
VIP会员
相关VIP内容
《用于代码弱点识别的 LLVM 中间表示》CMU
专知会员服务
14+阅读 · 2022年12月12日
【CIKM2022】基于双向Transformers对比学习的序列推荐
专知会员服务
21+阅读 · 2022年8月10日
【NeurIPS 2021】类比进化算法:设计统一的序列模型
专知会员服务
16+阅读 · 2021年10月30日
专知会员服务
46+阅读 · 2020年10月22日
相关资讯
【NeurIPS2019】图变换网络:Graph Transformer Network
NAACL 2019 | 一种考虑缓和KL消失的简单VAE训练方法
PaperWeekly
20+阅读 · 2019年4月24日
CNN 反向传播算法推导
统计学习与视觉计算组
30+阅读 · 2017年12月29日
相关基金
国家自然科学基金
2+阅读 · 2016年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员