Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Heap sorting in perl

by Ovid (Cardinal)
on Apr 05, 2003 at 15:08 UTC ( #248297=note: print w/replies, xml ) Need Help??

in reply to Heap sorting in perl

Can you give some examples where it's having problems? Perhaps we can figure out what's going on. To be fair, I haven't used, but I did notice that it's tests are not terribly comprehensive, so I'm not surprised. I confess a desire to see what's not working and start writing tests for it :)

If you happen to have a copy of "Mastering Algorithms with Perl", by O'Reilly, they have a heap implementation in there along with an excellent discussion. Perhaps rolling your own my help?


New address of my CGI Course.
Silence is Evil (feel free to copy and distribute widely - note copyright text)

Replies are listed 'Best First'.
Got to work... (was Re2: Heap sorting in perl)
by blakem (Monsignor) on Apr 06, 2003 at 03:12 UTC
    Thanks for the book tip... After skimming through the "Mastering Algorithms" section on heaps and reading through the source, I was able to build a small script that seems to work:
    #!/usr/bin/perl -wT use strict; use Heap::Binary; use Heap::Elem::Num; my $heap = Heap::Binary->new; for (25,33,107,5,42,29) { my $elem = Heap::Elem::Num->new($_); $heap->add( $elem ); } my $min = $heap->extract_minimum(); print "Min: " . $min->val . "\n"; # prints 5
    Unfortunately this doesn't exactly match the usage explained in the POD. It could be just a documentation bug, but it worries me a bit.


Re: Re: Heap sorting in perl
by Anonymous Monk on Apr 05, 2003 at 15:42 UTC
    I just attempted to download and install Heap. Its example broke for me upon attempting call add. (Not autoloaded.) Perl 5.6.1 on Linux here.

    Is anyone maintaining it? Is it worthwhile to file a bug report?

      I got the same error with Perl 5.8 on Linux. After a quick search turned up mixed reviews for the module, I decided to post here before making my next move. At the very least, I'll email the author of Heap with a bug report.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://248297]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2018-08-16 00:04 GMT
Find Nodes?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:

    Results (165 votes). Check out past polls.