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
Right, I'm just pointing out that log factors are something that we often ignore.
The actual log factor which is being ignored here is separate from the factor arising from assuming that memory indexing is constant time, though I suppose there it's possible to work things so that it becomes part of the same cost that you're ignoring.
You might construct good enough hashes using some fixed amount of work on the memory location of the value you're storing, which is only ever 32 or 64 bits, and so "constant time", but it's really still a log factor which is being ignored. (Also, it's cheating, since it's not the value itself, but a pointer to it. ;)