Skip to content
Official PYQ · 2025

GATE CS 2025 Set 1 Q55 — Searching, Sorting, Hashing

Explain with AI
In a double hashing scheme, h1(k)=k mod 11h_{1}(k)=k \bmod 11 and h2(k)=1+(k mod 7)h_{2}(k)=1+(k \bmod 7) are the auxiliary hash functions. The size mm of the hash table is 1111. The hash function for the ii-th probe in the open address table is [h1(k)+ih2(k)] mod m\left[h_{1}(k)+i h_{2}(k)\right] \bmod m. The following keys are inserted in the given order: 63,50,25,79,67,2463,50,25,79,67,24.

The slot at which key 2424 gets stored is ___________ . (Answer in integer)
View worked solution

Answer: 10:10

We are given a double hashing scheme with a hash table of size m=11m = 11 (slots 00 to 1010). The hash function for the ii-th probe is:

h(k,i)=[h1(k)+i⋅h2(k)] mod 11h(k, i) = \left[h_{1}(k) + i \cdot h_{2}(k)\right] \bmod 11

where h1(k)=k mod 11h_{1}(k) = k \bmod 11 and h2(k)=1+(k mod 7)h_{2}(k) = 1 + (k \bmod 7). Let's insert the keys step-by-step:

  1. Key 63: h1(63)=63 mod 11=8h_1(63) = 63 \bmod 11 = 8. Slot 8 is empty. Store 63 at slot 8.
  2. Key 50: h1(50)=50 mod 11=6h_1(50) = 50 \bmod 11 = 6. Slot 6 is empty. Store 50 at slot 6.
  3. Key 25: h1(25)=25 mod 11=3h_1(25) = 25 \bmod 11 = 3. Slot 3 is empty. Store 25 at slot 3.
  4. Key 79: h1(79)=79 mod 11=2h_1(79) = 79 \bmod 11 = 2. Slot 2 is empty. Store 79 at slot 2.
  5. Key 67: h1(67)=67 mod 11=1h_1(67) = 67 \bmod 11 = 1. Slot 1 is empty. Store 67 at slot 1.
  6. Key 24:
    • h1(24)=24 mod 11=2h_1(24) = 24 \bmod 11 = 2
    • h2(24)=1+(24 mod 7)=1+3=4h_2(24) = 1 + (24 \bmod 7) = 1 + 3 = 4
    • Probe i=0i = 0: h(24,0)=2h(24, 0) = 2 (occupied by 79)
    • Probe i=1i = 1: h(24,1)=(2+1×4) mod 11=6h(24, 1) = (2 + 1 \times 4) \bmod 11 = 6 (occupied by 50)
    • Probe i=2i = 2: h(24,2)=(2+2×4) mod 11=10h(24, 2) = (2 + 2 \times 4) \bmod 11 = 10 (empty)
    Store 24 at slot 10.

Thus, key 24 gets stored at slot 10.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Searching, Sorting, Hashing questions