This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs) focuses on “Hash Tables Chaining using Linked Lists”.
1. In a hash table of size 10, where is element 7 placed?
Explanation: The hash location is defined as hash(f)= key mod table_size.
7 mod 10 gives 7. It is placed in 7th position.
2. What should be the load factor for separate chaining hashing?
Explanation: The load factor should be held at 1 when hashing with a separate chaining process. It should not exceed 0.5 when using the open addressing process.
3. Which of the following operations are done in a hash table?
A) Insert only
B) Search only
C) Insert and search
Explanation: In order to implement Insert and Find operations in a constant average time, hash tables are used. The primary goal of hashing is to achieve this.
4. Which of the following is identical to that of a separate chaining hash node?
A) Linked list
Explanation: In separate chaining, the hash node is identical to that of a linked list. An array of connected lists makes up the separate chaining hash table.
5. Which of the following is the hashing function for separate chaining?
A) H(x)=(hash(x)+f(i)) mod table size
B) H(x)=hash(x)+i2 mod table size
C) H(x)=x mod table size
D) H(x)=x mod (table size * 2)
Explanation: H(x)= key mod table size is the hashing function for separate chaining. Quadratic probing is defined by H(x)=hash(x)+i2 mod table size.
6. What is the correct notation for a load factor?
Explanation: The load factor is commonly abbreviated as. The load factor is held at 1.0 in the separate chaining process.
7. In hash tables, how many traversal of links does a successful search require?
C) 1+ (⅄/2)
Explanation: A good search necessitates the traversal of approximately 1+ (/2) links. There’s a good chance you’ll have to go through at least one connection.
8. Which of the following is a disadvantage of using separate chaining using linked lists?
A) It requires many pointers
B) It requires linked lists
C) It uses array
D) It does not resolve collision
Explanation: The necessity of pointers is one of the big drawbacks of using separate chaining. More pointers are needed as the number of elements increases.
9. What is the worst case search time of a hashing using separate chaining algorithm?
A) O(N log N)
Explanation: Separate chaining algorithm using linked lists has a worst-case search time of O, according to mathematics (N).
10. From the given table, find ‘?’.
Given: hash(x)= x mod 10
Explanation: From the given options, 12 mod 10 hashes to 2 and hence ‘?’ = 12.
11. The case in which a key other than the desired one is kept at the identified location is called?
D) Open addressing
Explanation: A collision occurs when another value is positioned at a designated position other than the desired key.
12. What data organization method is used in hash tables?
C) Linked list
Explanation: The related list data structure is used to arrange data in hash tables. It has a data field as well as a pointer field.
13. The task of generating alternative indices for a node is called?
A) Collision handling
B) Collision detection
C) Collision recovery
D) Closed hashing
Explanation: The method of formulating alternative indices for a key is known as collision handling.
14. Which of the following is not a collision resolution technique?
A) Separate chaining
b) Linear probing
c) Quadratic probing
Explanation: Hashing is a method of storing information in unique locations. Hashing can cause collisions, but it is not a collision resolution technique.
15. Hashing is the problem of finding an appropriate mapping of keys into addresses.
Explanation: Hashing is a data structure that uses a key value to locate data in a table.
The hash table in the chaining method is an array of linked lists, with each index having its own linked list. Both key-value pairs that map to the same index are stored in that index’s linked list. Since each node in a linked list has a pointer to the next node, the nodes can be anywhere in memory. A hash table differs from both because its elements are not stored in any particular order. A hash table with a good hash function is a better option if you need a quick traversal.