Main

Hashing

Last updated 27 June 2026

Hashing

Hashing is a process during which an input, called the key, gets transformed into a fixed-size output, a hash value using a hash function.

Compression of Information

Information theory treats a hash function as a function that compresses information into fewer bits.

Since this hash mapping reduce the number of bits, information is necessarily lost. This causes an events called collisions where two keys map to the same hash value.

Good Hash Function

A good hash function exhibits high level of randomness.

Data Hashing

The goal of hashing in computer science applications is to place data into a fixed-sized structure efficiently. This includes:

This is achieved by interpreting the hash value of a piece of data as the index in that data structure.

h = hash(key)
index = h mod table_size

The Need for Speed

For arbitrary data, hashing is the only known practical method to achieve constant time lookup. This means that hash tables allow us to access and element in expected constant time.

Distributed Systems

Having a consistent hashing system allows distributed systems to unify in data storage and handle requests among clusters. Hashing eliminates the need for central command unifying local data storage systems.

← Back to Data structures