in reply to Re^2: Advanced Data Structure Question
in thread Advanced Data Structure Question

Given any list, a hashed search is the fastest way to find an element because it's generally O(1) (unlike O(logn) for binary searches), particularly if you have a limit on the number of elements as you do. You can use 1001 as your modulus and (with a little finagling) guarantee uniqueness in your buckets.

If you need to maintain order, do so by another data structure. In almost all cases, you can trade RAM for CPU.


My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

Replies are listed 'Best First'.
Re^4: Advanced Data Structure Question
by tilly (Archbishop) on Apr 20, 2006 at 00:59 UTC
    Given any list if memory access speed is constant, a hashed search averages fastest.

    Real computers do not have constant memory access time. A tree structure that preserves locality of reference can therefore be faster if the application has "hotspots".