Tag Archives: hash

Collision Resolution in Hash Table (by linked list)

Colision Resolution ( By separate chaining using linked list )

We have seen hash implementation in Array , where we can fill only one value in one slot. If new value comes it overwrites previous value. But using collision resolution by linked list we can resolve this problem and preserve the values. Whenever new value comes to the slot which is already filled then we can put new value in linked list associated with that slot.

In this method performance degrades when more values are matching with same slot.

The below picture is for hash table with collision resolution using channed linked list.

Hash function is key % 5


Collision Resolution in Hashtable in C


C Code for Collision Resolution in Hash Table is below


Hash implementation in Array (Direct Addressing)

C code to implement hash using array.

Description :

Hash can store only integer value. One slot can store only one value. Hash function is mod ( value % slots) .