# Data Structure Questions and Answers-Hash Tables

## Data Structure Questions and Answers-Hash Tables

 Question 1 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What is a hash table?
 A A structure that maps values to keys B A structure that maps keys to values C A structure used for storage D A structure used to implement stack and queue
Question 1 Explanation:
A hash table is used to implement associative arrays which has a key-value pair, so the has table maps keys to values.

 Question 2 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
If several elements are competing for the same bucket in the hash table, what is it called?
 A Diffusion B Replication C Collision D None of the mentioned
Question 2 Explanation:
None.

 Question 3 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
 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
Question 3 Explanation:
Direct addressing is possible only when we can afford to allocate an array that has one position for every possible key.

 Question 4 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What is the search complexity in direct addressing?
 A O(n) B O(logn) C O(nlogn) D O(1)
Question 4 Explanation:
Since every key has a unique array position, searching takes a constant time.

 Question 5 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What is a hash function?
 A A function has allocated memory to keys B A function that computes the location of the key in the array C A function that creates an array D None of the mentioned
Question 5 Explanation:
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.

There are 5 questions to complete.