algorithm - external sorting -
in web page:
http://web.eecs.utk.edu/~huangj/cs302s04/notes/external-sorting2.html
merge resulting runs successively bigger runs, until file sorted.
as quoted, how can merge resulting runs together??? don't hava memory.
imagine have numbers 1 - 9
9 7 2 6 3 4 8 5 1
and let's suppose 3 fit in memory @ time.
so you'd break them chunks of 3 , sort each, storing each result in separate file:
279 346 158
now you'd open each of 3 files streams , read first value each:
2 3 1
output lowest value 1
, , next value stream, have:
2 3 5
output next lowest value 2
, , continue onwards until you've outputted entire sorted list.
Comments
Post a Comment