No such thing as a small change | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Erm. No :-) You have to add all the items from the dataset to the heap before you can remove the N lowest (or highest, depending on the direction your grow your tree). Yes, you could have the heap as an out-of-memory structure. However, if the dataset is on disk you can just read it in element by element and use the algorithm I proposed. It's still going to be less expensive in time and space than creating a heap. Unless you are goin to be adding and removing entries from the data set and need to keep it ordered a heap is overkill for the problem as stated. In reply to Re^3: Heap sorting in perl
by adrianh
|
|