0% found this document useful (0 votes)
16 views4 pages

Collision

The document discusses collision resolution techniques for hashing. There are two main techniques: separate chaining and open addressing. Separate chaining handles collisions by making a linked list of slots for collided keys. Open addressing resolves collisions by probing for empty slots in the hash table. Common open addressing techniques are linear probing, quadratic probing, and double hashing which use different algorithms to determine where to probe for empty slots.

Uploaded by

bipasanaik282
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views4 pages

Collision

The document discusses collision resolution techniques for hashing. There are two main techniques: separate chaining and open addressing. Separate chaining handles collisions by making a linked list of slots for collided keys. Open addressing resolves collisions by probing for empty slots in the hash table. Common open addressing techniques are linear probing, quadratic probing, and double hashing which use different algorithms to determine where to probe for empty slots.

Uploaded by

bipasanaik282
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Collision in Hashing

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

use collision resolution techniques.

Collision Resolution Techniques


There are two types of collision resolution techniques.

• Separate chaining (open hashing)

• Open addressing (closed hashing)

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

of keys to add or remove.


Time complexity

• Its worst-case complexity for searching is o(n).

• Its worst-case complexity for deletion is o(n).

Advantages of separate chaining

• It is easy to implement.

• The hash table never fills full, so we can add more elements to the

chain.

• It is less sensitive to the function of the hashing.

Disadvantages of separate chaining

• In this, the cache performance of chaining is not good.

• Memory wastage is too much in this method.

• It requires more space for element links.

2. Open addressing or Closed Hashing: In this technique no key is kept

anywhere else besides the hash table. As a result, the hash table’s size

remains same not unequal just like separate chaining.

The following techniques are used in open addressing:

• Linear probing

• Quadratic probing

• Double hashing

a. Linear probing: This involves doing a linear probe for the following

slot when a collision occurs and continuing to do so until an empty

slot is discovered.
The worst time to search for an element in linear probing is O. The

cache performs best with linear probing, but clustering is a concern.

This method’s key benefit is that it is simple to calculate.

Disadvantages of linear probing:

• The main problem is clustering.

• It takes too much time to find an empty slot.

3. Quadratic probing: When a collision happens, we probe for the i2-nd

slot in the ith iteration, continuing to do so until an empty slot is

discovered. In comparison to linear probing, quadratic probing has a

worse cache performance. Additionally, clustering is less of a concern

with quadratic probing.


4. Double hashing: In this, we employ a different hashing algorithm, and

in the ith iteration, we look for (i * hash 2(x)). The determination of two

hash functions requires more time. Although there is no clustering

issue, the performance of the cache is relatively poor when using

double probing.

You might also like