Double Hashing - Disadvantages

Disadvantages

Linear probing and, to a lesser extent, quadratic probing are able to take advantage of the data cache by accessing locations that are close together. Double hashing has larger intervals and is not able to achieve this advantage. To avoid this situation, store your data with the second key as the row, and your first key as the column. Doing this allows you to iterate on the column, thus preventing cache problems. This also prevents the need to rehash the second key.

For instance:

pData int hv_1 = Hash(v) int hv_2 = Hash2(v) int original_hash = hv_1 while(pData){ hv_1 = hv_1 + 1 }


Like all other forms of open addressing, double hashing becomes linear as the hash table approaches maximum capacity. The only solution to this is to rehash to a larger size.

On top of that, it is possible for the secondary hash function to evaluate to zero. For example, if we choose k=5 with the following function:



The resulting sequence will always remain at the initial hash value. One possible solution is to change the secondary hash function to:



This ensures that the secondary hash function will always be non zero.


Essentially, Double Hashing is hashing on an already hashed key.

Read more about this topic:  Double Hashing