Consider a double hashing scheme in which the primary hash function is , and the secondary hash function is . Assume that the table size is 23. Then the address returned by probe 1 in the probe sequence (assume that the probe sequence begins at probe 0) for key value is ____.
GATE 2020 CS Q.23: solution and answer
Answer and solution
ANSWER
The address returned by probe 1 is 13.
Official answer: 13Source: Official answer key, GATE 2020 CS (IIT Delhi)
Double hashing probe formula: , with probe 0 corresponding to .
Compute . Since , the remainder is , so .
Compute . Since , the remainder is , so , giving .
Probe 0 address = .
Probe 1 address = .
So the address returned by probe 1 is .
KEY IDEA
Double hashing: the probe sequence address at step is , where probe 0 is the first probe ().
WATCH OUT FOR
Numbering probe 0 as (an off-by-one), which would compute probe 1 as and give the wrong address; or computing without the offset.
From the GATE 2020 CS paper. Every question of this paper · Download the full paper · All 18 Sorting & hashing questions, with notes
More Sorting & hashing questions
- GATE 2026 CS1 Q.24 · MSQ · 1 markConsider a hash table P[0,1,,10] that is initially empty. The hash table is maintained using open addressing…
- GATE 2026 CS2 Q.30 · NAT · 1 markThe keys 5, 28, 19, 15, 26, 33, 12, 17, 10 are inserted into a hash table using the hash function h(k) = k 9.
- GATE 2026 CS2 Q.32 · NAT · 1 markConsider an array A = [10, 7, 8, 19, 41, 35, 25, 31]. Suppose the merge sort algorithm is executed on array…
- GATE 2026 DA Q.31 · NAT · 1 markLet A be a sorted array containing 1000 distinct integers. You perform a recursive binary search on A to…
