The advantages and disadvantages of some of the collision resolution techniques are explained below −
Separate chaining is a hashing technique in which there is a list to handle collisions. So there are many elements at the same position and they are in a list. The sequences are maintained in a linked list.
The advantages of separate chaining hashing are as follows −
Separate chaining technique is not sensitive to the size of the table.
The idea and the implementation are simple.
The disadvantages of separate chaining hashing are as follows −
Keys are not evenly distributed in separate chaining.
Separate chaining can lead to empty spaces in the table.
The list in the positions can be very long.
Linear probing is a simple collision resolution technique for resolving collisions in hash tables, data structures for maintaining collection of values in a hash table. If there is a collision for the position of the key value then the linear probing technique assigns the next free space to the value.
The advantages of linear probing are as follows −
Linear probing requires very less memory.
It is less complex and is simpler to implement.
The disadvantages of linear probing are as follows −
Linear probing causes a scenario called "primary clustering" in which there are large blocks of occupied cells within the hash table.
The values in linear probing tend to cluster which makes the probe sequence longer and lengthier.
Quadratic probing also is a collision resolution mechanism which takes in the initial hash which is generated by the hashing function and goes on adding a successive value of an arbitrary quadratic polynomial from a function generated until an open slot is found in which a value is placed.
The advantages of quadratic probing is as follows −
Quadratic probing is less likely to have the problem of primary clustering and is easier to implement than Double Hashing.
The disadvantages of quadratic probing are as follows −
Quadratic probing has secondary clustering. This occurs when 2 keys hash to the same location, they have the same probe sequence. So, it may take many attempts before an insertion is being made.
Also probe sequences do not probe all locations in the table.
Double hashing is also a collision resolution technique when two different values to be searched for produce the same hash key.
It uses one hash value generated by the hash function as the starting point and then increments the position by an interval which is decided using a second, independent hash function. Thus here there are 2 different hash functions.
The advantage of double hashing is as follows −
Double hashing finally overcomes the problems of the clustering issue.
The disadvantages of double hashing are as follows:
Double hashing is more difficult to implement than any other.
Double hashing can cause thrashing.