25. What is a hash table collision? How can it be prevented?
This is one of the important data analyst interview questions.
The sample answer is…
When two separate keys hash to a common value, a hash table collision occurs. This means that two different data cannot be stored in the same slot.
Hash collisions can be avoided by two methods :
· Separate chaining – In this method, a data structure is used to store multiple items hashing to a common slot.
· Open addressing – This method seeks out empty slots and stores the item in the first empty slot available.