Skip to content
Official PYQ · 2026

GATE CS 2026 Set 2 Q20 — Searching, Sorting, Hashing

Explain with AI
The keys 5,28,19,15,26,33,12,17,105,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)
View worked solution

Answer: 3:3

To find the length of the longest chain, we compute the hash value h(k)=k mod 9h(k) = k \bmod 9 for each given key and group them by their hash index (from 00 to 88):

  • Index 0: None
  • Index 1: 28 mod 9=128 \bmod 9 = 1, 19 mod 9=119 \bmod 9 = 1, 10 mod 9=110 \bmod 9 = 1   →\rightarrow   Keys: {28,19,10}\{28, 19, 10\} (Chain length = 33)
  • Index 2: None
  • Index 3: 12 mod 9=312 \bmod 9 = 3   →\rightarrow   Keys: {12}\{12\} (Chain length = 11)
  • Index 4: None
  • Index 5: 5 mod 9=55 \bmod 9 = 5   →\rightarrow   Keys: {5}\{5\} (Chain length = 11)
  • Index 6: 15 mod 9=615 \bmod 9 = 6, 33 mod 9=633 \bmod 9 = 6   →\rightarrow   Keys: {15,33}\{15, 33\} (Chain length = 22)
  • Index 7: None
  • Index 8: 26 mod 9=826 \bmod 9 = 8, 17 mod 9=817 \bmod 9 = 8   →\rightarrow   Keys: {26,17}\{26, 17\} (Chain length = 22)

The longest chain occurs at index 11 with 33 keys. Thus, the length of the longest chain is 33.

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

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