IAE Academy

GATE 2020 CS Q.23: solution and answer

GATE 2020 · CSQ.23 · 1 mark · NAT

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 ____.

See the question in the paper

Answer and solution

ANSWER

The address returned by probe 1 is 13.

Official answer: 13Source: Official answer key, GATE 2020 CS (IIT Delhi)

  1. Double hashing probe formula: , with probe 0 corresponding to .

  2. Compute . Since , the remainder is , so .

  3. Compute . Since , the remainder is , so , giving .

  4. Probe 0 address = .

  5. Probe 1 address = .

  6. 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