You are on page 1of 6

DATA STRUCTURES AND ALGORITHMS

Assignment 3
Muhammad Ali Arif

F20604037

Submitted to:

Dr. Muhammad Umair

DEPARTMENT OF COMPUTER ENGINEERING


Linear Probing:

Code:

Output:
Quadratic Probing:

Code:

Output:
Double Hashing:

Output:
Conclusion

In conclusion, double hashing ,linear probing and quadratic probing are three
methods used in data structures to resolve collisions when inserting data into a
hash table.

Double hashing uses a secondary hash function to resolve collisions by


determining a different index for the data to be inserted. This approach can reduce
the probability of long chains of collisions and increase the overall efficiency of
the hash table. However, it requires additional computation time and the choice of
secondary hash function can have a significant impact on the performance of the
hash table.

Linear probing, on the other hand, simply looks for the next available slot in the
hash table to insert the data in case of a collision. This method is simple and easy
to implement, but can result in clustering, where multiple data items are stored
close to each other, which can degrade the performance of the hash table.

Quadratic probing is a method used in data structures to resolve collisions in a hash


table. Like linear probing, it is used when two or more data items hash to the same
index in the table. However, instead of simply looking for the next available slot in
the table, as in linear probing, quadratic probing uses a formula to determine the
next index to search for an available slot.

You might also like