In open addressing, linear probing is a collision resolution technique. What happens when a collision occurs during insertion?
Think about how linear probing searches for the next available position.
Linear probing resolves collisions by checking the next slot in the table sequentially until it finds an empty slot to insert the new item.
In quadratic probing, what is the maximum number of probes needed to find an empty slot in a hash table of size m (where m is prime and the table is less than half full)?
Consider the properties of quadratic probing and the load factor.
When the table size m is prime and the load factor is less than 0.5, quadratic probing guarantees finding an empty slot within at most m/2 probes.
Given a hash table of size 11, and two hash functions h1(key) = key % 11 and h2(key) = 1 + (key % 10), what is the probe sequence for inserting key 27 using double hashing?
Calculate h1(27) and h2(27), then apply the formula (h1(key) + i * h2(key)) % 11 for i = 0, 1, 2, ...
Calculate h1(27) = 27 % 11 = 5 and h2(27) = 1 + (27 % 10) = 1 + 7 = 8. The probe sequence is (5 + i*8) % 11 for i = 0..10, which results in 5, 2, 10, 7, 4, 1, 9, 6, 3, 0, 8.
Which collision handling method in open addressing is least prone to primary clustering?
Consider how the probe sequences differ and how clustering forms.
Double hashing uses a second hash function to calculate probe steps, which spreads out keys more evenly and reduces primary clustering compared to linear and quadratic probing.
Why is deletion in open addressing hash tables more complicated than insertion or search?
Think about how probe sequences depend on continuous slots.
Deleting an element by simply clearing its slot can break the probe sequence, causing searches for other keys that collided and were placed further along to fail. Special markers (like 'deleted' flags) are used to avoid this problem.