Given 20 GB of data (normally numbers) and you have only 1GB of RAM, How will you sort the data?
Asked
Active
Viewed 118 times
-3
-
2The question does not seem as bad, but you should also post your own thoughts and the efforts you took to solve it. – Abhishek Bansal May 31 '14 at 06:45
-
possible duplicate of [Interview puzzle: Sorting a million number input with limited memory](http://stackoverflow.com/questions/13775784/interview-puzzle-sorting-a-million-number-input-with-limited-memory). The numbers are different, but I don't believe that affects the solutions. – Paul Hankin May 31 '14 at 14:02
1 Answers
1
You can use something similar to merge sort.
Sort 20 groups of numbers and write them to disk. Once their sorted read from all groups simultaneously using a buffer and print out the ordered master set. For this last merge step you should only need constant memory.

cjungel
- 3,701
- 1
- 25
- 19