In a double hashing scheme, \(β„Ž_1 (π‘˜) = π‘˜ \ mod \ 11\) and \(β„Ž_2 (π‘˜) = 1 +…

2025

In a double hashing scheme,Β \(β„Ž_1 (π‘˜) = π‘˜ \ mod \ 11\) andΒ \(β„Ž_2 (π‘˜) = 1 + (π‘˜ \ mod \ 7)\) are the auxiliary hash functions. The sizeΒ \(m\) of the hash table is 11. The hash function for the \(i\)-th probe in the open address table is \([β„Ž_1 (π‘˜) + 𝑖 \ β„Ž_2(π‘˜)] \ mod \ π‘š\). 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)

Attempted by 33 students.

Show answer & explanation

Correct answer: 10

Insert the keys in the given order and compute h1 and h2 for each to find the probe sequence.

  1. Key 63: h1 = 63 mod 11 = 8; h2 = 1 + (63 mod 7) = 1. Probe i=0 -> slot (8 + 0*1) mod 11 = 8. Place 63 at slot 8.

  2. Key 50: h1 = 50 mod 11 = 6; h2 = 1 + (50 mod 7) = 2. Probe i=0 -> slot 6. Place 50 at slot 6.

  3. Key 25: h1 = 25 mod 11 = 3; h2 = 1 + (25 mod 7) = 5. Probe i=0 -> slot 3. Place 25 at slot 3.

  4. Key 79: h1 = 79 mod 11 = 2; h2 = 1 + (79 mod 7) = 3. Probe i=0 -> slot 2. Place 79 at slot 2.

  5. Key 67: h1 = 67 mod 11 = 1; h2 = 1 + (67 mod 7) = 5. Probe i=0 -> slot 1. Place 67 at slot 1.

  6. Key 24: h1 = 24 mod 11 = 2; h2 = 1 + (24 mod 7) = 4.

    Probe i=0 -> slot (2 + 0*4) mod 11 = 2 (occupied by 79).

    Probe i=1 -> slot (2 + 1*4) mod 11 = 6 (occupied by 50).

    Probe i=2 -> slot (2 + 2*4) mod 11 = (2 + 8) mod 11 = 10 (free). Place 24 at slot 10.

Final answer: 10 (slot 10)

A video solution is available for this question β€” log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir