COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
When a collision occurs with a hashing function, what is one method for dealing with the collisions?
|
creating a new list at that index
|
|
creating a new array
|
|
creating a new hash table
|
|
creating a new binary tree
|
Explanation:
Detailed explanation-1: -If there is any collision (i.e. two different elements have same hash value) then store both the elements in the same linked list. The cost of a lookup is that of scanning the entries of the selected linked list for the required key.
Detailed explanation-2: -One method for resolving collisions looks into the hash table and tries to find another open slot to hold the item that caused the collision. A simple way to do this is to start at the original hash value position and then move in a sequential manner through the slots until we encounter the first slot that is empty.
There is 1 question to complete.