algorithm - 对 100 万个查询进行排序

标签 algorithm

I have 1 million queries on disk to sort, my local memory/cache can store
up to 1 thousand queries, how can I perform sort?

这是一个谷歌面试问题。谁能帮我找到答案?

最佳答案

您将 1000 个查询加载到内存中,并使用 quicksort 对它们进行排序,然后将它们写入文件。最后,您将拥有 1000 个这样的文件。

然后您继续使用mergesort 合并文件。

我就是这样做的。绝不是最佳解决方案。

关于algorithm - 对 100 万个查询进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12036855/

相关文章:

arrays - 如何使用笛卡尔树将数组从索引 i 多次反转到索引 j?

c# - 试图找到在图中导航一组边的最快方法

java - 根据其中一个字段对元组进行排序

c++ - 使用 Cuda 的排序算法。内仁还是外仁?

java - 打包问题: items into constrained bins (Solution to singular matrix)

algorithm - 计算图像之间的差异

algorithm - Hadoop-计算单词共现(边缘情况)

python - python 中将此列表更改为另一个列表的功能方法

algorithm - 使用堆栈遍历树时如何跟踪树的深度?

c# - 您知道 Gauss Newton 和 Levenberg Marquardt 方法的 C# 实现吗?