Collision
Collision
In this, the hash function is used to find the index of the array. The hash value
is used to create an index for the key in the hash table. The hash function may
return the same hash value for two or more keys. When two or more keys
have the same hash value, a collision happens. To handle this collision, we
1. Separate chaining: This method makes a linked list out of the slot
during collision by adding the new key to the list. Separate chaining is
the term used to describe how this connected list of slots makes a chain.
It is more frequently utilized when we are not sure about the number
• It is easy to implement.
• The hash table never fills full, so we can add more elements to the
chain.
anywhere else besides the hash table. As a result, the hash table’s size
• Linear probing
• Quadratic probing
• Double hashing
a. Linear probing: This involves doing a linear probe for the following
slot is discovered.
The worst time to search for an element in linear probing is O. The
in the ith iteration, we look for (i * hash 2(x)). The determination of two
double probing.