14

Dynamic perfect hash tables and cuckoo hash tables are two different data structures that support worst-case O(1) lookups and expected O(1)-time insertions and deletions. Both require O(n) auxiliary space and access to families of hash functions for their operations.

I think that both of these data structures are beautiful and brilliant in their own right, but I'm not sure I see how and when one of these would be preferable over the other.

Are there specific contexts in which one of these data structures has a clear advantage over the other? Or are they mostly interchangeable?

D.W.
  • 167,959
  • 22
  • 232
  • 500
templatetypedef
  • 9,302
  • 1
  • 32
  • 62

4 Answers4

4

In cuckoo hashing, lookups can be performed in parallel, while in Dietzfelbinger et al.'s original dynamic perfect hashing scheme, lookups require two chained memory accesses, in which the second access uses information retrieved from the first.

jbapple
  • 3,390
  • 18
  • 21
3

Dynamic perfect hashing in the sense of Dietzfelbinger et al. only needs 2-independent hashing. While there are some results on simple hashing for cuckoo hash tables, such as twisted tabulation hashing and "Explicit and Efficient Hash Families Suffice for Cuckoo Hashing with a Stash", the original dynamic perfect hashing is more robust in some sense.

jbapple
  • 3,390
  • 18
  • 21
2

It is relatively easy to increase the space efficiency of cuckoo hashing by allowing each slot to hold more than one item. For slots of size 4, the space efficiency is something like 95%. That is to say, items can be inserted until 95% of the space in the table is used to hold items, not just places where items might go.

On the other hand, the bounds in the Dietzfelbinger et al. paper on dynamic perfect hashing only prove that insert operations can proceed as long as the table is no more than 3% full.

jbapple
  • 3,390
  • 18
  • 21
1

Cuckoo hashing uses $O(1)$ memory blocks at any one time and needs to free or reallocate memory rarely. Dynamic perfect hashing in the sense of Dietzfelbinger uses $O(n)$ memory blocks and will use more space in both internal and external fragmentation. There are ways to avoid this, but they add complexity to the algorithm.

jbapple
  • 3,390
  • 18
  • 21