Chaining (Hash Collision)
Chaining is to use a LinkedList
along side with HashTable to resolve collision.
In the case where collision happens. We use a LinkedList
to store for the same index.
For example:
If we have hash(austin) = 3
, we can just insert it as a LinkedList
We have the following:
Next if we do hash(github, 4)
, supposed that we hae a hash collision. Therefore hash(github, 4) = 3
. We can just extends it as a LinkedList
Doing this when searching, we also need to make sure we walk through all the possible LinkedList
inside a cell as well. However we don't have the cyclic problem as Open Addressing (Hash Collision) because of the Probing Sequence