2-choice hashing

Some collision resolution scheme is needed, unless keys are kept in buckets.

Having two hash functions allows any key x to have up to two potential locations to be stored based on the values of the respective outputs, h1(x) and h2(x).

The most important functions of the hashing implementation in this case are insertion and search.

As is true with all hash tables, the performance is based on the largest bucket.

Although there are instances where bucket sizes happen to be large based on the values and the hash functions used, this is rare.

This improvement is due to the randomized concept known as The Power of Two Choices.

There is little improvement (and no change to the expected order statistics) if more than two hash functions are used: "Additional hash functions only decrease the maximum by a constant factor.

[3] 2-left hashing—using two hash tables of equal size n/2, and asymmetrically resolving ties by putting the key in the left hash table—has fewer collisions and therefore better performance than 2-choice hashing with one large hash table of size n.[4][full citation needed] This article incorporates public domain material from Paul E. Black.