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

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.