Hashing Basics and Functions MCQs: 12 Solved Questions with Explanations
Attempt 12 solved hashing MCQs, then use the step-by-step solutions to revise functions, collisions, load factor, and operation costs.
KnowledgeGate Team
Exam prep & CS education

Hashing MCQs mix definitions with calculations, so a learner who knows the words can still lose track of what the hash function does, how collisions are handled, or when a performance claim applies. Attempt each of the 12 questions below before reading its answer, and use GATE Guidance by Sanchit Sir when you need the full theory sequence.
1. Hashing basics to recall before attempting the MCQs
A hash table stores keys at indices produced by a hash function. In the common division method, h(k) = k mod m, where key k is mapped into a table of m slots. A collision occurs when two distinct keys map to the same index. The load factor is alpha = n/m, where n is the number of stored elements.
For a table of size m = 57:
177 = 3 x 57 + 6, so177 mod 57 = 6. Key 177 goes to index 6.197 = 3 x 57 + 26, so197 mod 57 = 26. Key 197 goes to index 26.
For n = 7 elements and m = 10 slots, alpha = 7/10 = 0.7. This means the number of stored elements is 70 per cent of the number of slots.

2. Questions 1-3: collision, hash table, and hash-function meaning
Question 1
What does collision mean in the context of Hashing?
A. When two keys hash to the same index
B. When a key hashes to an index that is out of range
C. When two keys hash to different indexes
D. None of the above
Answer: A. A collision means distinct keys share a valid index. For example, 27 mod 10 = 7 and 37 mod 10 = 7, so both keys map to index 7. This is not an out-of-range result. With a valid modulo hash into m slots, every output lies from 0 to m - 1.
Question 2
Which data structure uses a "hash function" to store and retrieve data?
A. Array
B. Linked List
C. Hash Table
D. Tree
Answer: C. A hash table uses the function to map a key to a bucket index. It may use an array of buckets, but key-to-index mapping and collision handling make it a hash table.
Question 3
What is the purpose of a Hash Function in a Hash Table?
A. It is used to store keys
B. It is used to compute an index into an array of buckets, to which the desired value is then appended
C. It is used to compare keys for equality
D. None of the above
Answer: B. The hash function computes a bucket index. It does not itself store the key or prove that two keys are equal. An equality check is still needed to distinguish different keys that happen to reach the same bucket.
3. Questions 4-6: distribution and average-case performance
Question 4
Which one of the following hash functions on integers will distribute keys most uniformly over 10 buckets numbered 0 to 9 for i ranging from 0 to 2020?
A. h(i) = i² mod 10
B. h(i) = i³ mod 10
C. h(i) = (11 x i²) mod 10
D. h(i) = (12 x i) mod 10
Answer: B. Test the ten possible input residues. Cubing 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 modulo 10 gives 0, 1, 8, 7, 4, 5, 6, 3, 2, 9. This is a permutation of all ten bucket indices, so each residue class reaches a different bucket. Squaring reaches only 0, 1, 4, 5, 6, 9. Multiplication by 11 does not change those squared results modulo 10, while 12i mod 10 reaches only the even buckets 0, 2, 4, 6, 8.
Question 5
What is the average time complexity of operations (insert, delete, fetch) in a well-constructed Hash Table?
A. O(1)
B. O(log n)
C. O(n)
D. O(n^2)
Answer: A. A suitable hash function, controlled load factor, and effective collision handling give average-case O(1) insertion, deletion, and lookup. It is not an unconditional worst-case guarantee. If many keys collide and form a long search path, an operation can degrade to O(n).
Question 6
Which data structure is used for efficient searching, insertion, and deletion of elements?
A. Stack
B. Queue
C. Hash Table
D. More than one of the above
E. None of the above
Answer: C. A hash table supports these operations efficiently through average-case bucket access. A stack and queue specialise in ordered access, not arbitrary key lookup.
4. Questions 7-9: division and folding hash-function methods
Question 7
Using the division method [h(k) = k mod m], at which positions are the key values 177 and 197 stored in a hash table when the size of the hash table is 57?
A. 6, 26
B. 7, 27
C. 26, 6
D. 27, 7
Answer: A. For the first key, 177 = 3 x 57 + 6, so 177 mod 57 = 6. For the second, 197 = 3 x 57 + 26, so 197 mod 57 = 26. The answer reports the indices in the same order as the keys: 177 first, then 197.
Question 8
Which of the following is not used to calculate Hash Functions?
A. Folding Method
B. Modular Method
C. Division Method
D. Rehashing
Answer: D. Folding and division or modular arithmetic are methods for constructing hash values. Rehashing instead rebuilds or remaps table entries after the original setup, or may be used as part of a collision strategy.
Question 9
Which method of Hashing involves dividing the key into parts and adding them?
A. Division method
B. Mid-square method
C. Folding method
D. Multiplication method
Answer: C. Folding splits a key into parts and combines them. As an explanatory example, split 123456 as 12 | 34 | 56. Then 12 + 34 + 56 = 102. For a table with 10 slots, 102 mod 10 = 2, so the folded result maps to index 2.
5. Questions 10-12: collision handling and load factor
Question 10
Which of the following techniques can be used to handle collisions in a Hash Table?
A. Chaining
B. Open Addressing
C. Both A and B
D. None of the above
Answer: C. Chaining keeps collided keys in a structure associated with the same bucket. Open addressing probes other slots within the table. Both are collision-handling techniques.
Question 11
In a hash table, the load factor primarily represents which of the following?
A. Number of collisions per bucket
B. Ratio of stored elements to the total number of slots
C. Number of hash functions used
D. Total memory occupied by the hash table
E. Maximum size of a hash key
Answer: B. Load factor measures occupancy as alpha = n/m. Seven elements in ten slots gives alpha = 7/10 = 0.7. It does not directly count collisions, although increasing occupancy can affect collision behaviour and performance.
Question 12
What is the formula for calculating load factor (α) in Hash table? (Where n is number of elements and tsize is table size.)
A. α = tsize/n
B. α = n × tsize
C. α = n/tsize
D. α = n + tsize
Answer: C. Substitute n = 12 and tsize = 16: alpha = n/tsize = 12/16 = 0.75. Reversing the ratio gives 16/12 = 1.33, a misleading value above 1 even though this table is only partly filled.
6. What these questions are really testing
Question group | Topic | Decision skill |
|---|---|---|
Q1-Q3 | Definition | Separate the table, hash function, collision, and equality check |
Q4-Q6 | Quality and cost | Test residue distribution and qualify average-case performance |
Q7-Q9 | Hash-function arithmetic | Apply division and folding without losing the key order |
Q10-Q12 | Collision handling plus occupancy | Choose a handling method and compute |
Before moving on, check these common traps:
A good hash function reduces uneven distribution, but does not eliminate all collisions.
A hash function chooses an index. Collision resolution decides what happens when that index is already in use.
When two keys are given, report their calculated indices in the same order.
Load factor is
n/m, notm/n.Average-case
O(1)must never be presented as a worst-case guarantee.
For deeper theory, read Hashing and Collision Resolution. Then attempt the broader Hashing MCQs collection, which extends the mix to probing and chaining.
7. Answer key, revision route, and next step
Answer key: 1-A, 2-C, 3-B, 4-B, 5-A, 6-C, 7-A, 8-D, 9-C, 10-C, 11-B, 12-C
Use your score as study guidance. With 10 to 12 correct, move to collision-resolution traces. With 7 to 9, redo Questions 7 to 12 and show every calculation. With 0 to 6, rebuild the basic concept set before starting another timed set.
Now follow a three-step routine: retry every wrong item without looking at the answer, explain the correct option aloud, and retest yourself after two days. Use the CS Fundamentals category to choose an adjacent subject. For a complete Data Structures learning path, return to GATE Guidance by Sanchit Sir; for placement-oriented CS revision, use CS Fundamentals for Placements by Sanchit Sir.
Keep learning

Stack Basics and Operations MCQs: 12 Solved Questions with Step-by-Step Explanations
Test stack fundamentals through 12 exam MCQs on LIFO, TOP, array bounds, queue transfers and permutations. Complete traces make every state and answer checkable.

Evaluation of Expressions MCQs: 12 Solved Questions with Stack Traces
Solve 12 expression MCQs step by step. Trace postfix and prefix evaluation, nesting depth, precedence and notation conversion without reversing operands.

Priority Queue MCQs: 12 Solved Questions on Heaps, Deques and Variants
Attempt 12 verified priority queue and queue-variant MCQs, then learn from concise heap, array, circular queue and deque traces.

Infix, Postfix and Prefix MCQs: 12 Solved Questions with Step-by-Step Explanations
Solve 12 expression-notation MCQs in increasing difficulty, from basic stack use to conversions, associativity and maximum operand-stack depth.