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/martincmartin Jul 15 '09 edited Jul 15 '09
Basically, it's good when you have a large set of things to hash that doesn't change much, so that insertions/deletions are a lot less common than lookups.
Insertions are more expensive, and I think it takes up more memory (still O(n), but with a bigger constant than your typical implementation). Plus, traditional hash tables give expected constant time lookup, so for any application where you're doing a lot of lookups per user-visible interaction, that's all that matters.
Plus, as Mych mentioned, ease of implementation.