# Applications, Advantages and Disadvantages of Hash Data Structure

• Last Updated : 07 Jun, 2022

Hash or Hash table is a data structure that maps keys to values using a special function called a hash function. Hash stores the data in an associative manner. It stores data in an array where each data value has its own unique index. Hashing provides secure access and retrieval of the data.

Collision Resolution: Collision resolution in hash can be done by two methods:

Open Addressing: Open addressing collision resolution technique involves generating a location for storing or searching the data called probe. It can be done in the following ways:

• Linear Probing: If there is a collision at i then we use the hash function – H(k, i ) = [H'(k) + i ] % m
where, i is the index, m is the size of hash table H( k, i ) and H'( k ) are hash functions.
• Quadratic Probing: If there is a collision at i then we use the hash function –  H(k, i ) = [H'(k) + c1 * i + c2 * i2 ] % m
where, i is the index, m is the size of hash table H(k, i ) and H'( k ) are hash functions, c1 and c2 are constants.
• Double Hashing: If there is a collision at i then we use the hash function – H(k, i ) = [H1(k, i) + i * H2(k) ] % m
where, i is the index, m is the size of hash table H(k, i ), H1( k) = k % m and H2(k) = k % m’ are hash functions.

Closed addressing collision resolution technique involves chaining. Chaining in the hashing involves both array and linked list. In this method, we generate a probe with the help of the hash function and link the keys to the respective index one after the other in the same index. Hence, resolving the collision.

Applications of Hash:

• Hash is used in databases for indexing.
• Hash is used in disk based data structures.
• In some programming languages like Python, JavaScript hash is used to implement objects.

Real-Time Applications of Hash:

• Hash is used for cache mapping for fast access of the data.
• Hash can be used for password verification.
• Hash is used in cryptography as a message digest.