Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^5: Heap sorting in perl

by Aristotle (Chancellor)
on Apr 07, 2003 at 08:49 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2024-04-26 05:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found