in reply to Re: Data structure challenge
in thread Data structure challenge

Just as tye says, the problem is in the initialization. If you assign a value in a vec() string, and it's "out of bounds", perl will zero all the in between values.

That means, that if you were to store just one value, say U - 1, that insertion will cost you Θ (U) time. Which isn't O (1).

Abigail

Replies are listed 'Best First'.
Re: Re: Data structure challenge
by BrowserUk (Patriarch) on Mar 17, 2004 at 20:50 UTC

    I thought it was too easy.

    So the whole challenge comes down to is there any way to allocate/extend a piece of memory without initialising it, using pure perl?


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail