Question

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)+i h2(k)] mod m[h_1(k) + i\, h_2(k)] \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)

Official answer and solution
Accepted answers
10 to 11
From
Official GATE 2025 answer key

Solution

Insert the first five keys using h1(k)=k mod 11h_1(k) = k \bmod 11, then probe i=0,1,2,…i = 0, 1, 2, \dots for key 2424 using h1(24)=2h_1(24) = 2 and h2(24)=4h_2(24) = 4.

  1. Insert the first 5 keys (i=0i = 0):
    • k=63k = 63: h1(63)=63 mod 11=8  ⟹  h_1(63) = 63 \bmod 11 = 8 \implies Slot 8
    • k=50k = 50: h1(50)=50 mod 11=6  ⟹  h_1(50) = 50 \bmod 11 = 6 \implies Slot 6
    • k=25k = 25: h1(25)=25 mod 11=3  ⟹  h_1(25) = 25 \bmod 11 = 3 \implies Slot 3
    • k=79k = 79: h1(79)=79 mod 11=2  ⟹  h_1(79) = 79 \bmod 11 = 2 \implies Slot 2
    • k=67k = 67: h1(67)=67 mod 11=1  ⟹  h_1(67) = 67 \bmod 11 = 1 \implies Slot 1
  2. Insert k=24k = 24:
    • h1(24)=24 mod 11=2h_1(24) = 24 \bmod 11 = 2 and h2(24)=1+(24 mod 7)=1+3=4h_2(24) = 1 + (24 \bmod 7) = 1 + 3 = 4.
    • Probe i=0i = 0: [2+0×4] mod 11=2[2 + 0 \times 4] \bmod 11 = 2 (occupied by 7979).
    • Probe i=1i = 1: [2+1×4] mod 11=6[2 + 1 \times 4] \bmod 11 = 6 (occupied by 5050).
    • Probe i=2i = 2: [2+2×4] mod 11=10[2 + 2 \times 4] \bmod 11 = 10 (empty!).

Thus key 2424 is stored at slot 10 (or 11 if 1-indexed; official key accepts 10 to 11).

Final answer

10 (10 to 11 accepted)

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2025 Computer Science and Information Technology - Session 1 (CS1)
Question
65 of 65
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.