Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^5: Heap sorting in perl

by Aristotle (Chancellor)
on Apr 07, 2003 at 08:49 UTC ( #248540=note: print w/replies, xml ) Need Help??

in reply to Re: Re: Heap sorting in perl
in thread Heap sorting in perl

In said note, blakem writes:
Heap sorting is attractive because selecting the smallest M elements from a dataset of size N (N being much larger than M) requires storing only M elements in memory at any one time.
That means that he can very well store the entire heap, the M elements, in memory.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re^5: Heap sorting in perl
by Anonymous Monk on Apr 07, 2003 at 11:33 UTC
    Abigail's original solution as I read it requires that the entire dataset of size N be passed into the function smallest(). This requires that you have enough memory for N things up front. Which is the original poster's problem, he doesn't. He only comfortably has room for M things, but is fetching through a much larger dataset of N.

    Abigail's follow-up solution resolves this limitation admirably well...

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://248540]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2021-12-01 03:09 GMT
Find Nodes?
    Voting Booth?

    No recent polls found