Perl-Sensitive Sunglasses | |
PerlMonks |
Re: Heap sorting in perlby Abigail-II (Bishop) |
on Apr 06, 2003 at 21:04 UTC ( [id://248475]=note: print w/replies, xml ) | Need Help?? |
Your algorithm runs in Omega (N k log k), where N is the
size of the set, and you are interested in the k smallest
elements. Which is pretty lousy. With k for instance N / 100,
your algorithm is worse than doing a bubble sort of the entire
set, and getting the k smallest from the sorted set.
Abigail
In Section
Seekers of Perl Wisdom
|
|