Sort Big File
约 1 分钟· 本文阅读 次
本页目录
Sort Big File
Imagine you have a 20 GB file with one string per line. Explain how you would sort the file
Solution
As we can't store everything in the memory, we need to just store part of the data. Suppose we have 2 GB memory, we will split the data into 10 sets and each time we use in-place sorting algorithm to sort the 2GB data.
After 10 times of sorting, now the 20GB data is partially in-order. What we need to do is merge these 10 sets one by one to get the whole data sorted.
相关文章
- Binary Search2016-01-11
- Count Plane2016-01-11
- 名人问题2016-01-11
- Find Peak Element2016-01-11
已恢复到上次阅读位置