in reply to Re^10: Re-orderable keyed access structure?
in thread Re-orderable keyed access structure?

I was going to address this at some point, but to be honest, I've lost interest. So I decided to post a closing note instead of letting this silently slip into oblivion.

The point I was going to make is that your heap code is not exactly efficient. The algorithm description is formulated recursively, but you don't need to implement it that way. Since it's just tail recursion, you can trivially write it iteratively, which would gain a lot of ground.

Still, that would almost certainly only accelerate the code by a constant factor, which does not make it worth the effort for the smallish data sets you're working with.

I confess my surprise to find Perl is that slow. I am no stranger to optimizing Perl, but I've never come across such a stellar disparity between a builtin and explicit code before.

Makeshifts last the longest.

  • Comment on Re^11: Re-orderable keyed access structure?

Replies are listed 'Best First'.
Re^12: Re-orderable keyed access structure?
by BrowserUk (Patriarch) on Aug 25, 2004 at 21:35 UTC

    By all means rewrite the recursive routines iteratively and re-run the benchmark, but to be realistic, you would need to run this one.

    However, even if the iterative approach was 3 orders of magnitude faster than the recursive (which I strongly doubt), it still leaves the original problem of how to retain keyed access to the data stored in the array after it has been re-ordered.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon