Hashing: GATE CS Previous Year Questions

Hashing · Data Structures

19 questions · asked in 14 of 27 years (2000–2026)

MCQ 13 · MSQ 2 · NAT 41-mark 10 · 2-mark 9

2000Questions per year2026

Questions 1–5 of 19

Q1GATE 2026 (Session 1)1 markMSQ
Consider a hash table P[0,1,…,10]P[0,1, \ldots, 10] that is initially empty. The hash table is maintained using open addressing with linear probing. The hash function used is h(x)=(x+7) mod 11h(x)=(x+7) \bmod 11.

Consider the following sequence of insertions performed on PP :

 1,13, 22, 15, 11, 24\text { 1,13, 22, 15, 11, } 24

Which of the following positions in the hash table is/are empty after these insertions are performed?

One or more options are correct.

Q2GATE 2026 (Session 2)1 markNAT
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)

Q3GATE 2025 (Session 1)2 marksNAT
In a double hashing scheme, h1(k)=kmod  11h_1(k) = k \mod 11 and h2(k)=1+(kmod  7)h_2(k) = 1 + (k \mod 7) are the auxiliary hash functions. The size mm of the hash table is 11. The hash function for the ii-th probe in the open address table is [h1(k)+ih2(k)]mod  m[h_1(k) + i h_2(k)] \mod m 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)

Q4GATE 20231 markMCQ−0.33 if wrong
An algorithm has to store several keys generated by an adversary in a hash table. The adversary is malicious who tries to maximize the number of collisions. Let kk be the number of keys, mm be the number of slots in the hash table, and k>mk \gt m.
Which one of the following is the best hashing strategy to counteract the adversary?

Q5GATE 20221 markMCQ−0.33 if wrong
Suppose we are given nn keys, mm hash table slots, and two simple uniform hash functions h1h_1 and h2h_2. Further suppose our hashing scheme uses h1h_1 for the odd keys and h2h_2 for the even keys. What is the expected number of keys in a slot?

Keep practising

Topics in Data Structures

All CS topics ›