Collision handling in open addressing is a method to resolve conflicts when two keys hash to the same index by finding another open slot within the hash table itself.
Click to reveal answer
beginner
Name three common probing techniques used in open addressing.
The three common probing techniques are linear probing, quadratic probing, and double hashing.
Click to reveal answer
beginner
How does linear probing work in open addressing?
Linear probing checks the next slot sequentially (index + 1, index + 2, etc.) until it finds an empty slot to place the new key.
Click to reveal answer
intermediate
What problem can occur with linear probing and how is it called?
Linear probing can cause clustering, where groups of filled slots form, increasing search time. This is called primary clustering.
Click to reveal answer
intermediate
Explain double hashing in open addressing.
Double hashing uses a second hash function to calculate the step size for probing, reducing clustering by spreading out keys more evenly.
Click to reveal answer
What does open addressing do when a collision occurs?
AFinds another empty slot in the hash table
BStores the key in a linked list
CDeletes the existing key
DIgnores the new key
✗ Incorrect
Open addressing resolves collisions by searching for another empty slot within the hash table.
Which probing method checks slots sequentially after a collision?
ALinear probing
BDouble hashing
CQuadratic probing
DSeparate chaining
✗ Incorrect
Linear probing checks the next slots one by one in order.
What is the main disadvantage of linear probing?
ASlow hash function
BSecondary clustering
CHigh memory usage
DPrimary clustering
✗ Incorrect
Linear probing can cause primary clustering, where filled slots group together and slow down operations.
Which technique uses a second hash function to find the next slot?
AQuadratic probing
BLinear probing
CDouble hashing
DSeparate chaining
✗ Incorrect
Double hashing uses a second hash function to calculate the step size for probing.
In open addressing, what happens if the table is full?
AKeys are stored outside the table
BInsertion fails because no empty slot is available
CThe table automatically expands
DOld keys are overwritten
✗ Incorrect
If the hash table is full, open addressing cannot insert new keys because no empty slots remain.
Describe how open addressing handles collisions in a hash table.
Think about how the table itself is used to resolve conflicts.
You got /3 concepts.
Compare linear probing and double hashing as collision handling methods.
Focus on how they find the next slot and their impact on clustering.
You got /3 concepts.
Practice
(1/5)
1. What is the main idea behind open addressing in collision handling?
easy
A. Find another empty spot in the hash table when a collision occurs
B. Store collided elements in a separate linked list
C. Use multiple hash functions to avoid collisions
D. Resize the hash table immediately after a collision
Solution
Step 1: Understand collision handling methods
Open addressing handles collisions by searching for another empty slot inside the hash table itself.
Step 2: Compare with other methods
Unlike chaining (which uses linked lists), open addressing keeps all data inside the array by probing for free spots.
Final Answer:
Find another empty spot in the hash table when a collision occurs -> Option A
Quick Check:
Open addressing = find empty spot inside table [OK]
Hint: Open addressing means searching inside the table for free spots [OK]
Common Mistakes:
Confusing open addressing with chaining
Thinking collisions are ignored
Assuming resizing happens immediately on collision
2. Which of the following is the correct syntax to start linear probing from index i in a hash table of size m?
easy
A. next_index = (i - 1) % m
B. next_index = (i * 2) % m
C. next_index = (i + 1) % m
D. next_index = (i + m) % 2
Solution
Step 1: Recall linear probing formula
Linear probing moves to the next slot by adding 1 to the current index and wrapping around using modulo.
Step 2: Apply modulo with table size
To stay within the table size, use (i + 1) % m, where m is the table size.
Final Answer:
next_index = (i + 1) % m -> Option C
Quick Check:
Linear probing = increment index by 1 modulo table size [OK]
Hint: Linear probing adds 1 and wraps with modulo table size [OK]
Common Mistakes:
Using multiplication instead of addition
Incorrect modulo divisor
Subtracting instead of adding
3. Given a hash table of size 5 and a hash function h(k) = k % 5, if keys 7, 12, and 17 are inserted using linear probing, what will be the final index of key 17?