Sail E0 Webinar

MCQs

Total Questions : 10
Question 1. When is it appropriate to use direct addressing?
  1.    When the array is comparatively large
  2.    When the universe U of keys is reasonably small
  3.    When the universe U of keys is reasonably large
  4.    When the array is comparatively small
 Discuss Question
Answer: Option B. -> When the universe U of keys is reasonably small


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.


Question 2. What is the advantage of using a dynamic set in direct addressing?
  1.    It saves time
  2.    It saves space
  3.    It saves both time and space
  4.    None of the mentioned
 Discuss Question
Answer: Option B. -> It saves space


Using a dynamic set, the size of the array is restricted to the number of keys, hence saves space.


Question 3. What is the time complexity to insert an element into the direct address table?
  1.    O(n)
  2.    O(logn)
  3.    O(nlogn)
  4.    O(1)
 Discuss Question
Answer: Option D. -> O(1)


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


Question 4. What is the search complexity in direct addressing?
  1.    O(n)
  2.    O(logn)
  3.    O(nlogn)
  4.    O(1)
 Discuss Question
Answer: Option D. -> O(1)


Since every key has a unique array position, searching takes a constant time.


Question 5. What is the time complexity to delete an element from the direct address table?
  1.    O(n)
  2.    O(logn)
  3.    O(nlogn)
  4.    O(1)
 Discuss Question
Answer: Option D. -> O(1)


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.


Question 6. If several elements are competing for the same bucket in the hash table, what is it called?
  1.    Diffusion
  2.    Replication
  3.    Collision
  4.    None of the mentioned
 Discuss Question
Answer: Option C. -> Collision




Question 7. What is direct addressing?
  1.    Distinct array position for every possible key
  2.    Fewer array positions than keys
  3.    Fewer keys than array positions
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> Distinct array position for every possible key


Direct addressing is possible only when we can afford to allocate an array that has one position for every possible key.


Question 8. What can be the techniques to avoid collision?
  1.    Make the hash function appear random
  2.    Use the chaining method
  3.    Use uniform hashing
  4.    All of the mentioned
 Discuss Question
Answer: Option D. -> All of the mentioned


Making the hash function random is not really a good choice, although it is considered one of the techniques to avoid collisions along with chaining and simple uniform hashing.


Question 9. What is the search complexity in direct addressing?
  1.    O(n)
  2.    O(logn)
  3.    O(nlogn)
  4.    O(1)
 Discuss Question
Answer: Option D. -> O(1)


Since every key has a unique array position, searching takes a constant time


Question 10. What is a hash function?
  1.    A function has allocated memory to keys
  2.    A function that computes the location of the key in the array
  3.    A function that creates an array
  4.    None of the mentioned
 Discuss Question
Answer: Option B. -> A function that computes the location of the key in the array


In a hash table, there are fewer array positions than the keys, so the position of the key in the array has to be computed, this is done using the hash function.


Latest Videos

Latest Test Papers