Hash Tables and Collision Resolution Short Notes for GATE DA
Hash Tables and Collision Resolution short notes for GATE DA: 2 study cards covering concepts, formulas, shortcuts and exam traps, plus solved practice questi
hash tables and collision resolution short notes
Quick Revision: Open Addressing and Linear Probing
Quick Revision
Key Takeaways
1. Open Addressing
All elements reside strictly inside the hash table array.
No external linked lists or pointers.
2. Linear Probing
Resolves collisions by checking the next sequential slot.
Formula: hi(x)=(h(x)+i)(modm).
Wraps around to index 0 after reaching m−1.
3. Deletion Trap
Cannot mark deleted slots as empty.
Must use tombstones to preserve probe chains.
4. Primary Clustering
Contiguous blocks of occupied slots form clusters.
Degrades performance significantly as clusters grow.
Answer it here to see how it works. Nothing is recorded until you sign in.
Question 1
Level 1: Warm-up
Match the operations with their corresponding expected number of probes for a hash table with load factor α.
List I (Operation):
P. Unsuccessful Search
Q. Insertion
R. Successful Search
List II (Formula):
1−α1
α1ln(1−α1)
Question 2
Level 1: Warm-up
For a hash table of size m using linear probing, what is the formula for the i-th probe index for a key x, given the base hash function h(x)?
Question 3
Level 1: Warm-up
Consider the following assertion and reason:
Assertion (A): In the worked example with m=10 and h(x)=3x(mod10), the key 14 is stored at index 4.
Reason (R): The initial hash of 14 is 2, and slots 2 and 3 are occupied.
Question 4
Level 1: Warm-up
Consider the following assertion and reason:
Assertion (A): The expected number of probes for inserting a new element into a hash table with load factor α=0.5 is 2.
Reason (R): Insertion requires finding an empty slot, which is mathematically identical to an unsuccessful search, given by 1−α1.
Question 5
Level 1: Warm-up
Consider the following assertion and reason:
Assertion (A): For a hash table with load factor α=0.5, the expected number of probes for a successful search is 2.
Reason (R): The successful search formula is α1ln(1−α1), which for α=0.5 gives 2ln(2)≈1.39.
Question 6
Level 1: Warm-up
When deleting a key from a hash table that uses linear probing, why is it insufficient to simply mark the slot as completely empty?
Question 7
Level 1: Warm-up
When inserting keys into a linear probing hash table of size m=10, what is the minimum number of probes needed to insert a key if the table already has 5 elements?
Question 8
Level 1: Warm-up
Match the keys with their final indices in a linear probing hash table of size m=10 with h(x)=3x(mod10), after inserting keys 2, 5, 12 in that order.
List I (Keys): 2, 5, 12
List II (Indices): 6, 5, 7
Question 9
Level 1: Warm-up
The expected number of probes for a successful search in a hash table with load factor α is α1ln(1−α1). What is the minimum possible value of this expected number of probes as the table becomes very sparse (α→0)?
Question 10
Level 1: Warm-up
Consider the following statements about hash table probe complexity under uniform hashing:
P: The expected probes for successful search is α1ln(1−α1).
Q: This formula is valid for all α≥0.
R: For α=0.5, the expected probes for successful search is less than for unsuccessful search.
Which of the statements are true?
Free preview ends here
Login to view the complete short notes
Creating an account is free. You get the rest of this chapter, step-by-step solutions, and a study plan built around the topics you are actually weak at.
Most platforms hand everyone the same content. Here the content moves with your performance, topic by topic.
Built around you, not around a syllabus PDF
Every answer you give moves your topic-level intelligence rate. The next question, the next revision card and tomorrow's plan all change with it.
Revision that hits your weak spots
We only revise topics you have actually attempted and are still below the safe bar on — never the same chapter on repeat.
Questions calibrated to the real exam
Each question carries a measured toughness. You are served a rung above your current level, so practice keeps stretching you.
Notes written for recall, not for volume
Full lesson cards for first study, curated short-note cards for the last mile — with derivations, traps and exam patterns marked.
One place for everything
Notes, chapter practice, previous-year questions, test series and full-length papers — all feeding one picture of your preparation.
Honest progress
No vanity streaks. Progress here means chapters mastered and accuracy that held up on harder questions.
Unlock the whole course
Full notes and short notes, the complete question bank with worked solutions, mock tests, full-length papers, and an adaptive plan that rebuilds itself as you improve.
Hash Tables and Collision Resolution Short Notes for GATE DA
Hash Tables and Collision Resolution short notes for GATE DA: 2 study cards covering concepts, formulas, shortcuts and exam traps, plus solved practice questions.
Quick Revision: Open Addressing and Linear Probing
Quick Revision
Key Takeaways
1. Open Addressing
All elements reside strictly inside the hash table array.
No external linked lists or pointers.
2. Linear Probing
Resolves collisions by checking the next sequential slot.
Formula: hi(x)=(h(x)+i)(modm).
Wraps around to index 0 after reaching m−1.
3. Deletion Trap
Cannot mark deleted slots as empty.
Must use tombstones to preserve probe chains.
4. Primary Clustering
Contiguous blocks of occupied slots form clusters.
Degrades performance significantly as clusters grow.
Hash Tables and Collision Resolution: Solved Questions with Step-by-Step Explanations (10 Problems)
Question 1 · Programming, Data Structures and AlgorithmsMCQ
Match the operations with their corresponding expected number of probes for a hash table with load factor α.
List I (Operation):
P. Unsuccessful Search
Q. Insertion
R. Successful Search
List II (Formula):
1−α1
α1ln(1−α1)
A.
P-1, Q-1, R-2
B.
P-1, Q-2, R-1
C.
P-2, Q-1, R-1
D.
P-1, Q-2, R-2
Correct Answer:
A
Step-by-Step Solution
Key idea: This is a match-the-following question testing your ability to map hash table operations to their correct probe complexity formulas.
Step 1: Unsuccessful Search (P). Probing until an empty slot is found. Formula: 1−α1. Matches 1.
Step 2: Insertion (Q). Probing until an empty slot is found to place the new element. This is identical to an unsuccessful search. Formula: 1−α1. Matches 1.
Step 3: Successful Search (R). Searching for a key already in the table. Formula: α1ln(1−α1). Matches 2.
Final mapping: P-1, Q-1, R-2.
Common trap: A student might misread the condition for insertion and think it requires a successful search formula, matching Q with 2.
Answer: P-1, Q-1, R-2
Question 2 · Programming, Data Structures and AlgorithmsMCQ
For a hash table of size m using linear probing, what is the formula for the i-th probe index for a key x, given the base hash function h(x)?
A.
(h(x)imesi)(modm)
B.
(h(x)+i2)(modm)
C.
(h(x)+i)(modm)
D.
(h(x)−i)(modm)
Correct Answer:
C
Step-by-Step Solution
Key idea: This is a direct recall question about the linear probing formula.
Step 1: Recall that linear probing resolves collisions by checking the next sequential slot.
Step 2: The formula for the i-th probe is the base hash plus the probe number i, all modulo the table size m.
Step 3: This matches (h(x)+i)(modm).
Answer: C
Question 3 · Programming, Data Structures and AlgorithmsMCQ
Consider the following assertion and reason:
Assertion (A): In the worked example with m=10 and h(x)=3x(mod10), the key 14 is stored at index 4.
Reason (R): The initial hash of 14 is 2, and slots 2 and 3 are occupied.
A.
Both A and R are true, and R is the correct explanation of A.
B.
Both A and R are true, but R is NOT the correct explanation of A.
C.
A is true but R is false.
D.
A is false but R is true.
Correct Answer:
A
Step-by-Step Solution
Key idea: This is an assertion-reason question testing the worked example of linear probing.
Step 1: Verify Assertion (A). For key 14, h(14)=3×14(mod10)=42(mod10)=2. Slot 2 is occupied by key 4. Probe slot 3, occupied by key 1. Probe slot 4, which is empty. So key 14 is stored at index 4. Assertion (A) is true.
Step 2: Verify Reason (R). The initial hash of 14 is indeed 2. Slots 2 and 3 are occupied (by keys 4 and 1, respectively). Reason (R) is true.
Step 3: Check if (R) explains (A). Yes, (R) correctly explains why key 14 ends up at index 4: it hashes to 2, finds slots 2 and 3 occupied, and probes to slot 4.
Both (A) and (R) are true, and (R) is the correct explanation of (A).
Common trap: A student might compute the hash as 42 (forgetting modulo) and think (R) is false. This is a unit mismatch error (not applying modulo).
Answer: A
Question 4 · Programming, Data Structures and AlgorithmsMCQ
Consider the following assertion and reason:
Assertion (A): The expected number of probes for inserting a new element into a hash table with load factor α=0.5 is 2.
Reason (R): Insertion requires finding an empty slot, which is mathematically identical to an unsuccessful search, given by 1−α1.
A.
Both A and R are true and R is the correct explanation of A.
B.
Both A and R are true but R is NOT the correct explanation of A.
C.
A is true but R is false.
D.
A is false but R is true.
Correct Answer:
A
Step-by-Step Solution
Key idea: This is an assertion-reason question testing the conceptual link between insertion and unsuccessful search complexities.
Step 1: Verify Assertion (A). The expected probes for insertion with α=0.5 is calculated using the unsuccessful search formula: E=1−α1=1−0.51=0.51=2. Assertion (A) is true.
Step 2: Verify Reason (R). Insertion requires probing until an empty slot is found. This is the exact definition of an unsuccessful search (probing until an empty slot is found to conclude the key is absent). Thus, the formulas are identical. Reason (R) is true.
Step 3: Check if (R) explains (A). Yes, (R) correctly identifies that insertion is identical to an unsuccessful search, which is the exact reason why the formula 1−α1 yields 2 for α=0.5.
Both (A) and (R) are true, and (R) is the correct explanation of (A).
Common trap: A student might confuse insertion with a successful search, thinking (R) is false because "insertion is a successful operation". This is a unit mismatch of operation types.
Answer: A
Question 5 · Programming, Data Structures and AlgorithmsMCQ
Consider the following assertion and reason:
Assertion (A): For a hash table with load factor α=0.5, the expected number of probes for a successful search is 2.
Reason (R): The successful search formula is α1ln(1−α1), which for α=0.5 gives 2ln(2)≈1.39.
A.
Both A and R are true and R is the correct explanation of A.
B.
Both A and R are true but R is NOT the correct explanation of A.
C.
A is true but R is false.
D.
A is false but R is true.
Correct Answer:
D
Step-by-Step Solution
Key idea: This is an assertion-reason question testing the successful search formula and calculation.
Step 1: Evaluate Assertion (A). For α=0.5, the expected probes for successful search is:
E=0.51ln(1−0.51)=2ln(2)≈2×0.693=1.386
The assertion claims E=2, which is incorrect. A is FALSE.
Step 2: Evaluate Reason (R). The formula α1ln(1−α1) is correct, and the calculation 2ln(2)≈1.39 is also correct. R is TRUE.
Step 3: Since A is false and R is true, the answer is D.
Common trap: A unit mismatch error occurs if you confuse successful search with unsuccessful search. For α=0.5, unsuccessful search gives 1−0.51=2, which matches the assertion. But the question is about successful search.
Question 6 · Programming, Data Structures and AlgorithmsMCQ
When deleting a key from a hash table that uses linear probing, why is it insufficient to simply mark the slot as completely empty?
A.
It would change the hash function for all remaining keys.
B.
It would immediately trigger a full rehashing of the table.
C.
It would cause the hash table size to decrease automatically.
D.
It would break the probe chain for other keys that collided and were placed further down.
Correct Answer:
D
Step-by-Step Solution
Key idea: This is a concept recall question about the deletion trap in linear probing.
Step 1: In linear probing, a key that collides is placed in the next available slot.
Step 2: Searching for that key involves probing sequentially from its base hash until the key is found or an empty slot is encountered.
Step 3: If a deleted slot is marked as completely empty, a subsequent search for a key that was placed after it will incorrectly terminate at this "empty" slot, failing to find the key.
Step 4: Therefore, we must use a "tombstone" (deleted marker) instead of a truly empty marker to preserve the probe chain.
Answer: D
Question 7 · Programming, Data Structures and AlgorithmsMCQ
When inserting keys into a linear probing hash table of size m=10, what is the minimum number of probes needed to insert a key if the table already has 5 elements?
A.
0
B.
1
C.
5
D.
6
Correct Answer:
B
Step-by-Step Solution
Key idea: This is a minimum probe count question for linear probing.
Step 1: The table has 5 elements, so 5 slots are occupied and 5 are empty.
Step 2: In the best case, the key hashes directly to an empty slot on the first probe.
Step 3: Minimum probes = 1 (the initial probe finds an empty slot).
The minimum number of probes is 1.
Common trap: A student might think the answer is 5, assuming you need to probe past all existing elements. This ignores the constraint that the key might hash directly to an empty slot.
Answer: 1
Question 8 · Programming, Data Structures and AlgorithmsMCQ
Match the keys with their final indices in a linear probing hash table of size m=10 with h(x)=3x(mod10), after inserting keys 2, 5, 12 in that order.
List I (Keys): 2, 5, 12
List II (Indices): 6, 5, 7
A.
2-6, 5-5, 12-7
B.
2-7, 5-6, 12-5
C.
2-6, 5-7, 12-5
D.
2-5, 5-6, 12-7
Correct Answer:
A
Step-by-Step Solution
Key idea: This is a match-the-following question testing the final indices after insertion with linear probing.
Step 1: Insert key 2. h(2)=3×2(mod10)=6(mod10)=6. Slot 6 is empty. Key 2 is at index 6.
Step 2: Insert key 5. h(5)=3×5(mod10)=15(mod10)=5. Slot 5 is empty. Key 5 is at index 5.
Step 3: Insert key 12. h(12)=3×12(mod10)=36(mod10)=6. Slot 6 is occupied by key 2. Probe slot 7, which is empty. Key 12 is at index 7.
Final mapping: 2-6, 5-5, 12-7.
Common trap: A student might not probe correctly for key 12, thinking it goes to index 5 or 6 without checking for collisions. This is a misread condition error.
Answer: 2-6, 5-5, 12-7
Question 9 · Programming, Data Structures and AlgorithmsMCQ
The expected number of probes for a successful search in a hash table with load factor α is α1ln(1−α1). What is the minimum possible value of this expected number of probes as the table becomes very sparse (α→0)?
A.
0
B.
1
C.
e
D.
\infty
Correct Answer:
B
Step-by-Step Solution
Key idea: This is a bounding question testing the limit of the successful search formula as the load factor approaches 0.
Step 1: The formula for the expected number of probes in a successful search is E=α1ln(1−α1)=α−ln(1−α).
Step 2: As α→0, both the numerator −ln(1−α) and the denominator α approach 0. This is a 00 indeterminate form.
Step 3: Apply L'Hôpital's rule. The derivative of the numerator with respect to α is 1−α1. The derivative of the denominator is 1.
Step 4: Evaluate the limit as α→0:
limα→011−α1=1−01=1.
Common trap: A student might ignore the constraint that you always need at least 1 probe to check a slot, and incorrectly guess 0 because α→0.
Answer: 1
Question 10 · Programming, Data Structures and AlgorithmsMCQ
Consider the following statements about hash table probe complexity under uniform hashing:
P: The expected probes for successful search is α1ln(1−α1).
Q: This formula is valid for all α≥0.
R: For α=0.5, the expected probes for successful search is less than for unsuccessful search.
Which of the statements are true?
A.
P only
B.
P and Q only
C.
P and R only
D.
P, Q, and R
Correct Answer:
C
Step-by-Step Solution
Key idea: This is a statement truth question testing the successful search formula and its constraints.
Step 1: Evaluate statement P. The formula α1ln(1−α1) is the standard formula for successful search under uniform hashing. P is TRUE.
Step 2: Evaluate statement Q. The formula requires α>0 (to avoid division by zero in α1) and α<1 (to avoid ln of negative or undefined values). At α=0, the formula is undefined. Q is FALSE.