# Applications, Advantages and Disadvantages of Hash Data Structure

**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 and
- Closed addressing.

**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) + c**_{1}* i + c_{2}* i^{2}] % m

where,**i**is the index,**m**is the size of hash table**H(k, i )**and**H'( k )**are hash functions,**c**and_{1}**c**are constants._{2}**Double Hashing:**If there is a collision at**i**then we use the hash function –**H(k, i ) = [H**_{1}(k, i) + i * H_{2}(k) ] % m

where,**i**is the index,**m**is the size of hash table**H(k, i )**,**H**and_{1}( k) = k % m**H**are hash functions._{2}(k) = k % m’

**Closed Addressing:**

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.

__Advantages of Hash:__

- Hash provides better synchronization than other data structures.
- Hash tables are more efficient than search trees or other data structures.
- Hash provides constant time for searching, insertion and deletion operations on average.

__Disadvantages of Hash:__

- Hash is inefficient when there are many collisions.
- Hash collisions are practically not be avoided for large set of possible keys.
- Hash does not allow null values.