in reply to Re: Re: Heap sorting in perl
in thread Heap sorting in perl
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re^3: Heap sorting in perl
by Anonymous Monk on Apr 05, 2003 at 15:51 UTC | |
by adrianh (Chancellor) on Apr 05, 2003 at 16:29 UTC | |
by Anonymous Monk on Apr 05, 2003 at 17:02 UTC | |
by adrianh (Chancellor) on Apr 05, 2003 at 20:12 UTC |