in reply to Sparse Array

I need an implementation of a sparse array. If the searched key/index does not exist, it needs to return the immediately higher and immediately lower keys/indexes.
All binary search trees from data structures 101 will do that. If you keep it balanced, it will do such operations in O(log N) time.

Replies are listed 'Best First'.
Re^2: Sparse Array
by BrowserUk (Patriarch) on Jul 25, 2011 at 15:32 UTC
    All binary search trees from data structures 101 will do that.

    That is my 'Non-answer: pick-of-the-week'.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.