algorithm - 合并排序的 n 个列表

标签 algorithm sorting

如何解决对非常大的列表进行排序的问题?

我想我们划分列表并让它们在每个 CPU 中处理并生成小的排序列表。

但是我们如何组合并生成最终的排序列表呢?

最佳答案

您可以使用 priority queu 合并多个排序列表e(基于二叉堆)。

用对 (列表的当前元素或其索引;列表 id) 填充队列。

At every step: 
   extract pair with min element from queue
   add value to result
   get the next element of the same list (if possible)
   insert new pair into queue again

相对于可用内存,您的列表有多大?
有用的线索从wiki external sorting page开始

关于algorithm - 合并排序的 n 个列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51393954/

相关文章:

algorithm - AVL树中诱导的高度不平衡

algorithm - 存储用于流式传输的仅附加系列文件的最佳实践方法是什么?

Python ..访问默认排序功能?

ruby-on-rails - 如何按多个字符串降序对 Ruby 二维数组进行排序?

arrays - 使用排序对数组数组进行升序和降序排序

r - 更快的加权采样,无需替换

python - 河内代表塔

Java替换字符串中的一个字符

sorting - unix sort -n -t","给出意外结果

java - 列表的排序 View