250+ TOP MCQs on Hash Tables Chaining with List Heads and Answers

Data Structures & Algorithms Multiple Choice Questions on “Hash Tables Chaining with List Heads”.

1. Which of the following helps keys to be mapped into addresses?
a) hash function
b) separate chaining
c) open addressing
d) chaining using a linked list

Answer: a
Clarification: Hash table is an example of a data structure that is built for fast access of elements. Hash functions are used to determine the index of any input record in a hash table.

2. What is the advantage of the hash table over a linked list?
a) faster access of data
b) easy to implement
c) very efficient for less number of entries
d) exhibit good locality of reference

Answer: a
Clarification: Hash table is a data structure that has an advantage that it allows fast access of elements. But linked list is easier to implement as compared to the hash table.

3. Which of the following trait of a hash function is most desirable?
a) it should cause less collisions
b) it should cause more collisions
c) it should occupy less space
d) it should be easy to implement

Answer: a
Clarification: Hash function calculates and returns the index for corresponding data. So the most important trait of a hash function is that it should cause a minimum number of collisions.

4. What is the time complexity of insert function in a hash table using list head?
a) O(1)
b) O(n)
c) O(log n)
d) O(n log n)

Answer: a
Clarification: Time complexity of insert function in a hash table is O(1). Condition is that the number of collisions should be low.

5. What is the time complexity of search function in a hash table using list head?
a) O(1)
b) O(n)
c) O(log n)
d) O(n log n)

Answer: a
Clarification: Time complexity of search function in a hash table is O(1). Condition is that the number of collisions should be low.

6. What is the time complexity of delete function in the hash table using list head?
a) O(1)
b) O(n)
c) O(log n)
d) O(n log n)

Answer: a
Clarification: Time complexity of delete function in a hash table is O(1). Condition is that the hash function should be such that the number of collisions should be low.

7. A hash table may become full in the case when we use open addressing.
a) true
b) false

Answer: a
Clarification: A hash table may become full in the case when we use open addressing. But when we use separate chaining it does not happen.

8. What is the advantage of using linked list over the doubly linked list for chaining?
a) it takes less memory
b) it causes more collisions
c) it makes the process of insertion and deletion faster
d) it causes less collisions

Answer: a
Clarification: Singly linked list takes lesser space as compared to doubly linked list. But the time complexity of the singly linked list is more than a doubly linked list.

9. What is the worst case time complexity of insert function in the hash table when the list head is used for chaining?
a) O(1)
b) O(n log n)
c) O(log n)
d) O(n)

Answer: d
Clarification: Worst case time complexity of insert function in the hash table when the list head is used for chaining is O(n). It is caused when a number of collisions are very high.

10. Which of the following technique is used for handling collisions in a hash table?
a) Open addressing
b) Hashing
c) Searching
d) Hash function

Answer: a
Clarification: Open addressing is the technique which is used for handling collisions in a hash table. Separate chaining is another technique which is used for the same purpose.

11. By implementing separate chaining using list head we can reduce the number of collisions drastically.
a) True
b) False

Answer: b
Clarification: Collision is caused when a hash function returns repeated values. So collisions can be reduced by developing a better hash function. Whereas separate chaining using list head is a collision handling technique so it has no relation with a number of collisions taking place.

12. Which of the following is an advantage of open addressing over separate chaining?
a) it is simpler to implement
b) table never gets full
c) it is less sensitive to hash function
d) it has better cache performance

Answer: a
Clarification: Open addressing is the technique which is used for handling collisions in a hash table. It has a better cache performance as everything is stored in the same table.

Leave a Reply

Your email address will not be published. Required fields are marked *