Data Structures Multiple choice Questions and Answers on Direct Addressing Tables

https://www.computersprofessor.com/2017/11/data-structures-multiple-choice_3.html
1. What is direct addressing?
a) Distinct array position for every possible key
b) Fewer array positions than keys
c) Fewer keys than array positions
d) None of the mentioned
Answer: a
Explanation: Direct addressing is possible only when we can afford to allocate an array that has one position for every possible key.
2. When is it appropriate to use direct addressing?
a) When the array is comparatively large
b) When the universe U of keys is reasonably small
c) When the universe U of keys is reasonably large
d) When the array is comparatively small
Answer: b
Explanation: Since each key is associated with a slot in the array, it is better to use direct addressing when the universe of keys is small as the array size grows with the increase in number of keys.
3. What is the search complexity in direct addressing?
a) O(n)
b) O(logn)
c) O(nlogn)
d) O(1)
Answer: d
Explanation: Since every key has a unique array position, searching takes a constant time.
4. What is the time complexity to insert an element into the direct address table?
a) O(n)
b) O(logn)
c) O(nlogn)
d) O(1)
Answer: d
Explanation: As every key has a unique array position, it takes constant time to insert an element.
5. What is the advantage of using a dynamic set in direct addressing?
a) It saves time
b) It saves space
c) It saves both time and space
d) None of the mentioned
Answer: b
Explanation: Using a dynamic set, the size of the array is restricted to the number of keys, hence saves space.
6. 4. What is the time complexity to delete an element from the direct address table?
a) O(n)
b) O(logn)
c) O(nlogn)
d) O(1)
Answer: d
Explanation: As every key has a unique array position, it takes constant time to delete an element, although the deleted position must be specified by nil.
7. How is a bit vector better compared to a normal array for implementing the hash table?
a) It saves time
b) It saves space
c) It saves both time and space
d) None of the mentioned
Answer: b
Explanation: A bit vector is an array of bits of only 0s and 1s, a bit vector of length m takes much less space than an array of m pointers.