Engineering Questions with Answers - Multiple Choice Questions

Data Structure MCQ – Direct Addressing Tables

1 - Question

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) Distinct array positions for keys based on priority

View Answer

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 - Question

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

View Answer

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 - Question

What is the search complexity in direct addressing?
a) O(n)
b) O(logn)
c) O(nlogn)
d) O(1)

View Answer

Answer: d
Explanation: Since every key has a unique array position, searching takes a constant time.




4 - Question

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)

View Answer

Answer: d
Explanation: As every key has a unique array position, it takes constant time to insert an element.




5 - Question

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) It reduces code complexity

View Answer

Answer: b
Explanation: Using a dynamic set, the size of the array is restricted to the number of keys, hence saves space. The complexity to implement dynamic array is larger than in normal case.




6 - Question

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)

View Answer

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 - Question

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) It reduces code complexity

View Answer

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. The complexity to implement bit vector is larger than in normal case.

Get weekly updates about new MCQs and other posts by joining 18000+ community of active learners