Question

The keys 5, 28, 19, 15, 26, 33, 12, 17, 10 are inserted into a hash table using the hash function h(k)=k mod 9h(k) = k \bmod 9. The collisions are resolved by chaining. After all the keys are inserted, the length of the longest chain is __________. (answer in integer)

Official answer and solution
Official answer
3
From
Official GATE 2026 answer key

Solution

Compute k mod 9k \bmod 9 for each of the 9 keys and find the maximum bucket count.

Computing h(k)=k mod 9h(k) = k \bmod 9 for each key:

  • 5 mod 9=55 \bmod 9 = 5
  • 28 mod 9=128 \bmod 9 = 1
  • 19 mod 9=119 \bmod 9 = 1
  • 15 mod 9=615 \bmod 9 = 6
  • 26 mod 9=826 \bmod 9 = 8
  • 33 mod 9=633 \bmod 9 = 6
  • 12 mod 9=312 \bmod 9 = 3
  • 17 mod 9=817 \bmod 9 = 8
  • 10 mod 9=110 \bmod 9 = 1

Bucket counts:

  • Bucket 11: {28,19,10}\{28, 19, 10\} (length 33)
  • Bucket 33: {12}\{12\} (length 11)
  • Bucket 55: {5}\{5\} (length 11)
  • Bucket 66: {15,33}\{15, 33\} (length 22)
  • Bucket 88: {26,17}\{26, 17\} (length 22)

The length of the longest chain is 33.

Final answer

3

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

Source

Paper
GATE 2026 Computer Science and Information Technology - Session 2 (CS2)
Question
30 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.