IAE Academy

GATE 2025 CS1 Q.65: solution and answer

GATE 2025 · CS1Q.65 · 2 marks · NAT

In a double hashing scheme, and are the auxiliary hash functions. The size of the hash table is 11. The hash function for the -th probe in the open address table is . The following keys are inserted in the given order: 63, 50, 25, 79, 67, 24.

The slot at which key 24 gets stored is ________. (Answer in integer)

See the question in the paper

Answer and solution

ANSWER

The key 24 is stored at slot 10.

Official answer: 10 to 11Source: Official answer key, GATE 2025 CS1 (IIT Roorkee)

  1. Compute for the first five keys, which are inserted with no collisions since all slots differ: , , , , .

  2. Table after these insertions: slot 1 = 67, slot 2 = 79, slot 3 = 25, slot 6 = 50, slot 8 = 63; all other slots (0, 4, 5, 7, 9, 10) are empty.

  3. For key 24: .

  4. .

  5. Probe : — occupied by 79, so probing continues.

  6. Probe : — occupied by 50, so probing continues.

  7. Probe : — this slot is empty, so key 24 is stored at slot 10.

KEY IDEA

In double hashing, the probe sequence for a key is for ; since never depends on , each key traces a fixed "skip" sequence through the table until it lands on an empty slot.

WATCH OUT FOR

Forgetting that once a slot is found occupied, the probe sequence must be recomputed with the next value of i (not restarted or incremented incorrectly), and mixing up which key already occupies a slot — leading students to place 24 in slot 6 or slot 2 by mistake.

From the GATE 2025 CS1 paper. Every question of this paper · Download the full paper · All 18 Sorting & hashing questions, with notes

More Sorting & hashing questions