Introduction to Hashing (original) (raw)

Last Updated : 29 Jan, 2026

**Hashing refers to the process of generating a small sized output (that can be used as index in a table) from an input of typically large and variable size. Hashing uses mathematical formulas known as hash functions to do the transformation. This technique determines an index or location for the storage of an item in a data structure called Hash Table.

Introduction-to-Hashing

Introduction to Hashing

Hash Table Data Structure Overview

Situations Where Hash is not Used

Components of Hashing

There are majorly three components of hashing:

  1. **Key: A Keycan be anything string or integer which is fed as input in the hash function the technique that determines an index or location for storage of an item in a data structure.
  2. **Hash Function: Receives the input key and returns the index of an element in an array called a hash table. The index is known as the hash index .
  3. Hash Table: Hash table is typically an array of lists. It stores values corresponding to the keys. Hash stores the data in an associative manner in an array where each data value has its own unique index.

Components-of-Hashing

How does Hashing work?

Suppose we have a set of strings {“ab”, “cd”, “efg”} and we would like to store it in a table.

Mapping-Key-with-indices-of-Array

The above technique enables us to calculate the location of a given string by using a simple hash function and rapidly find the value that is stored in that location. Therefore the idea of hashing seems like a great way to store (key, value) pairs of the data in a table.

How to Create Your Own Hash Table?