Open addressing, or closed hashing, is a method of collision resolution in hash tables. With this method a hash collision is resolved by probing, or searching through alternate locations in the array (the probe sequence) until either the target record is found, or an unused array slot is found, which indicates that there is no such key in the table. Well known probe sequences include:
- Linear probing
- in which the interval between probes is fixed — often at 1.
- Quadratic probing
- in which the interval between probes increases linearly (hence, the indices are described by a quadratic function).
- Double hashing
- in which the interval between probes is fixed for each record but is computed by another hash function.
The main tradeoffs between these methods are that linear probing has the best cache performance but is most sensitive to clustering, while double hashing has poor cache performance but exhibits virtually no clustering; quadratic probing falls in-between in both areas. Double hashing can also require more computation than other forms of probing. Some open addressing methods, such as last-come-first-served hashing and cuckoo hashing move existing keys around in the array to make room for the new key. This gives better maximum search times than the methods based on probing.
A critical influence on performance of an open addressing hash table is the load factor; that is, the proportion of the slots in the array that are used. As the load factor increases towards 100%, the number of probes that may be required to find or insert a given key rises dramatically. Once the table becomes full, probing algorithms may even fail to terminate. Even with good hash functions, load factors are normally limited to 80%. A poor hash function can exhibit poor performance even at very low load factors by generating significant clustering. What causes hash functions to cluster is not well understood, and it is easy to unintentionally write a hash function which causes severe clustering.
Read more about Open Addressing: Example Pseudo Code
Famous quotes containing the words open and/or addressing:
“It is open to a war resister to judge between the combatants and wish success to the one who has justice on his side. By so judging he is more likely to bring peace between the two than by remaining a mere spectator.”
—Mohandas K. Gandhi (18691948)
“He took up his pen, which seemed to parch like a martyr in his hand. He began to write, nevertheless, addressing the nine-and-ninety lies of the moment he hoped with for a night of saloperie at the side of the twisted strumpet, Fiction, who lasciviously rolled her eyes at him, hiked up her skirt, and beckoned him on.”
—Alexander Theroux (b. 1940)