Query on the soln for algorithm for N-way merge -


i have query regard 1 of soln proposed algorithm n-way merge

the soln proposed member aioobe follows:

1. create priority queue  2. iterate through each file f     enqueue pair (nextnumberin(f), f) using first value priority key  3. while queue not empty     1. dequeue head (m, f) of queue     2. output m     3. if f not depleted         1. enqueue (nextnumberin(f), f) 

i did not understand steps 2 , 3 completely. step 2 need read contents of files priority queue ? if that's case, won't memory concern?

in step 3, did not understand 3.3 (if f not deplete, enqueue). 1 or op (aioobe) me here understand this. many thanks.

step 2 reads first number each file. shouldn't memory problem unless have ton of files or large numbers.

step 3.3 reads next number after m in same file m came from.


Comments