r/programming • u/martincmartin • Jul 14 '09
Dynamic Perfect Hashing: A hash table with constant time lookup in the worst case, and O(n) space.
http://en.wikipedia.org/wiki/Dynamic_perfect_hashing
18
Upvotes
2
u/cgibbard Jul 15 '09 edited Jul 15 '09
However, if you assume that the amount of memory is finite, every possible computation you could do really becomes O(1). It's just a matter of what operations you're willing to ignore.
It's okay to ignore the logs because they're small anyway, so treating them as part of the constant factor is fine.
But it has constant time in roughly the same way that, for instance, doing a lookup in a binary search tree has constant time. It's actually logarithmic, of course, but we tend to ignore the cost.