Hashing questions

Q24

GATE CS 2026 CS-1Searching Sorting and HashingMSQ1 mark
Consider a hash table P[0,1,…,10]P[0, 1, \dots, 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)(mod11)h(x) = (x + 7) \pmod{11}.

Consider the following sequence of insertions performed on PP:
1,13,22,15,11,241, 13, 22, 15, 11, 24

Which of the following positions in the hash table is/are empty after these insertions are performed?
More than one option can be correct.
Show answer without attempting

Answer: C

Q30

GATE CS 2026 CS-2Searching Sorting and HashingNAT1 mark
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)
Show answer without attempting

Answer: 3

Q65

GATE CS 2025 CS-1Searching Sorting and HashingNAT2 marks
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 11. The hash function for the i-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, 24.
The slot at which key 24 gets stored is ___________. (Answer in integer)
Show answer without attempting

Answer: 10 to 11

Q20

GATE CS 2023 CSSearching Sorting and HashingMCQ1 mark−1/3 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 > m.

Which one of the following is the best hashing strategy to counteract the adversary?
Show answer without attempting

Answer: C

Q16

GATE CS 2022 CSSearching Sorting and HashingMCQ1 mark−1/3 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?
Show answer without attempting

Answer: B

Q47

GATE CS 2021 CS-1Searching Sorting and HashingMSQ2 marks
Consider a dynamic hashing approach for 4-bit integer keys:
1. There is a main hash table of size 4.
2. The 2 least significant bits of a key is used to index into the main hash table.
3. Initially, the main hash table entries are empty.
4. Thereafter, when more keys are hashed into it, to resolve collisions, the set of all keys corresponding to a main hash table entry is organized as a binary tree that grows on demand.
5. First, the 3rd least significant bit is used to divide the keys into left and right subtrees.
6. To resolve more collisions, each node of the binary tree is further sub-divided into left and right subtrees based on the 4th least significant bit.
7. A split is done only if it is needed, i.e., only when there is a collision.
Consider the following state of the hash table.
Which of the following sequences of key insertions can cause the above state of the hash table (assume the keys are in decimal notation)?
Question figure
More than one option can be correct.
Show answer without attempting

Answer: C

Q23

GATE CS 2020 CSSearching Sorting and HashingNAT1 mark
Consider a double hashing scheme in which the primary hash function is h1(k)=k mod 23h_1(k) = k \bmod 23, and the secondary hash function is h2(k)=1+(k mod 19)h_2(k) = 1 + (k \bmod 19). Assume that the table size is 23. Then the address returned by probe 1 in the probe sequence (assume that the probe sequence begins at probe 0) for key value k=90k = 90 is __________.
Show answer without attempting

Answer: 13

Q22

GATE CS 2015 CS-3Searching Sorting and HashingNAT1 mark
Given a hash table TT with 25 slots that stores 2000 elements, the load factor α\alpha for TT is ____________.
Show answer without attempting

Answer: 80

Q50

GATE CS 2015 CS-2Searching Sorting and HashingMCQ2 marks−2/3 if wrong
Which one of the following hash functions on integers will distribute keys most uniformly over 10 buckets numbered 0 to 9 for ii ranging from 0 to 2020?
Show answer without attempting

Answer: B

Q40

GATE CS 2014 CS-3Searching Sorting and HashingMCQ2 marks−2/3 if wrong
Consider a hash table with 100 slots. Collisions are resolved using chaining. Assuming simple uniform hashing, what is the probability that the first 3 slots are unfilled after the first 3 insertions?
Show answer without attempting

Answer: A

Q40

GATE CS 2014 CS-1Searching Sorting and HashingMCQ2 marks−2/3 if wrong
Consider a hash table with 9 slots. The hash function is h(k)=k mod 9h(k) = k \text{ mod } 9. The collisions are resolved by chaining. The following 9 keys are inserted in the order: 5, 28, 19, 15, 20, 33, 12, 17, 10. The maximum, minimum, and average chain lengths in the hash table, respectively, are
Show answer without attempting

Answer: A

0/110 correct0 marks

Related topics in Searching Sorting and Hashing