Overview
Direct
Given a universe of keys , a direct-address table has slots. Each slot corresponds to a key in universe .
Closed
In closed addressing, a key is always stored in the bucket it’s hashed to. Collisions are dealt with using separate data structures on a per-bucket basis.
Ideal Hashing
An independent uniform hash function is the ideal theoretical abstraction. For each possible input in universe , an output is produced randomly and independently chosen from range . Once a value is chosen, each subsequent call to with the same input yields the same output .
Chaining
The most common form of closed addressing is chaining. In this scheme, each slot is a (nullable) pointer to the head of a linked list containing all the elements with hash value .
Open
In open addressing, keys always reside in the hash table. Collisions are dealt with by searching for other empty buckets within the hash table.
Sequential examination of slots during dictionary operations is called probing. Given hash function , the probe sequence refers to the sequence visited when probing. Every probe sequence is expected to be a permutation of .
Ideal Hashing
An independent uniform permutation hash function is the ideal theoretical abstraction in open addressing. The probe sequence of each key is equally likely to be any of the permutations of .
Bibliography
- “Hash Tables: Open vs Closed Addressing | Programming.Guide,” accessed June 12, 2024, https://programming.guide/hash-tables-open-vs-closed-addressing.html.
- Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).