algorithm - 在不使用额外数组的情况下实现归并排序?

标签 algorithm mergesort

我最近阅读了很多关于合并排序的文章,我想知道是否有一种方法可以在不使用至少一个额外数组的情况下进行合并排序。可能吗?

最佳答案

显然是这样。 This paper描述就地归并排序:

Two in-place variants of the classical mergesort algorithm are analysed in detail. The first, straightforward variant performs at most N log 2 N + O(N ) comparisons and 3N log 2 N + O(N ) moves to sort N elements. The second, more advanced variant requires at most N log 2 N + O(N ) comparisons and "N log 2 N moves, for any fixed " ? 0 and any N ? N ("). In theory, the second one is superior to advanced versions of heapsort. In practice, due to the overhead in the index manipulation, our fastest in-place mergesort behaves still about 50 per cent slower than the bottom-up heapsort. However, our implementations are practical compared to mergesort algorithms based on in-place merging.

Jyrki Katajainen、Tomi Pasanen、Jukka Teuhola,“实用就地合并排序”(1996 年)。

关于algorithm - 在不使用额外数组的情况下实现归并排序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2171517/

相关文章:

c - 需要使用数组指针、其长度和合并函数的工作空间数组在 C 中实现递归合并排序代码

java - 用 O(nlogn) 时间 O(1) 空间有效地计算数组中等值对的数量

algorithm - 傅里叶处理算法如何处理 "data edges"

algorithm - 冒泡排序为什么叫冒泡排序?

java方法返回null但不应该

c++ - 在 C++ 中将数组作为参数传递

c - 最快的多线程排序方法

algorithm - O(n^2) 与 O(n(logn)^2)

python - 如何递归遍历树并在python中创建访问节点列表

java - java中的合并排序和复制数组,仍然是nlogn?