When double spread value method or double hashing ( English double hashing ) is a method for realizing a closed hash method . In closed hash procedures, attempts are made to accommodate defectors in the hash table instead of storing them within the cell (e.g. as a list). (Open hash procedures can assign entries twice and therefore do not require any exploration.) Attention: As it is in the article hash table under "Variants of the hash procedure", the terms "open" or "closed hashing" are used in exactly the opposite way.
To do this, double hashing uses a probing function that includes a secondary hash function, e.g. B. , and which is used if the index calculated by the primary hash function is already occupied.
The full hash function then reads:, where j is the number of already "tried" indices, i. This means that j is increased by 1 every time an index is already used.
The probing function is supposed to form a permutation of the indices of the hash table.
The sequence of hash functions that are now formed using and looks like this:
The cost of this method is close to the cost of ideal hashing.
Double hashing uses two independent hash functions and . These are called independent if the probability of a so-called double collision, i.e. H. , is less than or equal to and therefore minimal, where is the size of the array.
The array filled with the help of hash table and probe function:
0
1
2
3
4th
5
6th
31
22nd
16
10
-
19th
14th
Explanation using the example :
and do not generate a collision and therefore do not need the double hash function . The index of the hash function can be read off here. creates a collision in the array at the point , which is why you now use the double hash function with :
The point creates a collision again, which is why the following is called with:
The position is vacant and thus receives the content .