Skip to content
ExamHope Logo

examhope

Primary Menu
  • Digital Logic
    • Arithmetic Operations
    • Asynchronous/Ripple Counters
    • Basic Gates
    • Boolean Algebraic Theorems
    • Codes
  • Data Structures
    • Binary Heaps
    • Binary Search
    • Binary Search Trees
    • Binary Tree
    • Binary Tree Sort
    • Bipartite Graphs
    • Complete Graph
  • Theory of Computation
    • Finite Automata
    • Finite Automaton First Example
  • Current Affairs
    • Sports News
    • Tech News
    • Bollywood News
    • Daily News
  • Database
  • Computer Network
  • Computer Organization and Architecture
  • C Language
  • Operating Systems
  • Software Engineering
  • Theory of Computation
  • About us
  • Contact Us
  • Privacy Policy
  • DMCA Policy
  • Terms and Conditions
  • Home
  • IT
  • Data Structures
  • Hashing
  • Hashing — Searching
  • Hashing

Hashing — Searching

examhopeinfo@gmail.com November 14, 2025 2 minutes read
Hashing

Hashing

🌟 What Is Hashing?

Hashing is a method of finding data super fast.
Instead of searching through the whole list, we use a special function called a hash function to calculate where the data should be stored.

Think of it like a smart shortcut.


🔑 Basic Idea

Hashing works in two main steps:

  1. Take a key (like a roll number or name).
  2. Run it through a hash function → get a unique number (called hash value or index).
  3. Store the data at that index in a table.

Later, when you want to search the data, you simply compute the same hash value again —
and jump straight to the location.

No scanning. No waiting.
Just direct access.


🗂️ Simple Example

Let’s say we want to store student roll numbers in a table of size 10.

Use a simple hash function:

[
h(key) = key % 10
]

Now let’s store roll number 23:

[
h(23) = 23 % 10 = 3
]

So we put 23 in index 3.

If we want to search for 23 later,
we again compute 23 % 10, get 3, and go straight to index 3.


🧩 Diagram (Simple Hash Table)

Hash Table (size 10)

Index : Data
------------------
0     :  -
1     :  -
2     :  -
3     :  23   ← h(23)=3
4     :  -
5     :  -
6     :  -
7     :  -
8     :  -
9     :  -

🎈 Real-Life Analogy

Imagine a classroom with 100 students.
Instead of shouting everyone’s name to mark attendance,
you say:

“Roll number 37!”

Immediately, the student at seat 37 stands up.

Hashing works exactly like that —
jumping straight to the exact seat (index) without checking anyone else.


⚠️ But There’s a Problem: Collisions

Sometimes, two different keys may land on the same index.

Example:

  • h(23) = 3
  • h(33) = 3

Both keys want to sit at the same seat.

This is called a collision, and it’s very common.

But don’t worry — we have ways to handle it.


🛠️ Collision Handling Techniques

1️⃣ Chaining

Each index stores a linked list of elements.

Index 3: 23 → 33 → 43

So if multiple keys land in the same index,
they form a chain.


2️⃣ Open Addressing

If an index is occupied, we look for the next empty spot.

Common methods are:

  • Linear Probing → check next index
  • Quadratic Probing → skip in squares
  • Double Hashing → use a second hash function

🎨 Diagram: Chaining (Collision Handling)

Hash Table (size 5)

Index : Data
-----------------------
0     :  -
1     :  11 → 21 → 31
2     :  -
3     :  18
4     :  -

Here:

  • h(11)=1
  • h(21)=1
  • h(31)=1

All of them store in index 1, forming a chain.


💻 Why Hashing Is Powerful

OperationAverage Time
InsertO(1)
SearchO(1)
DeleteO(1)

This means hashing gives constant-time performance in most cases.
That’s why hash tables are used in almost every major application —
databases, compilers, caches, dictionaries, etc.

About the Author

examhopeinfo@gmail.com

Administrator

Visit Website View All Posts

Post navigation

Previous: B Tree and B + Tree
Next: Directed Graph — Data Structures

Recent Posts

  • Vivo X200: जाने कितनी कम कीमत पर मिल रहा ये 9400 मिडिया टेक प्रोसेसर वाला स्मार्टफोन
  • Samsung Galaxy S25 Plus पर मिल रही भारी छूट ,जाने सेल प्राइस
  • AI के इस ज़माने में कैसे बिजली बचा रहे हैं यह स्मार्ट प्लग?
  • क्या है यह GhostPairing Scam और बिना पासवर्ड और सिम के क्यों हो रहा है व्हाट्सप्प अकाउंट हैक
  • Leica कैमरे के साथ जल्द लॉन्च हो सकता है Xiaomi Ultra 17

At ExamHope, we understand that preparing for exams can be challenging, overwhelming, and sometimes stressful. That’s why we are dedicated to providing high-quality educational resources, tips, and guidance to help students and aspirants achieve their goals with confidence. Whether you are preparing for competitive exams, school tests, or professional certifications, ExamHope is here to make your learning journey smarter, easier, and more effective.

Quick links

  • About us
  • Contact Us
  • Privacy Policy
  • Terms and Conditions
  • Disclaimer
  • DMCA Policy

Category

  • Computer Network
  • Computer Organization and Architecture
  • Data Structures
  • C Language
  • Theory of Computation
  • Database

You may have missed

Vivo X200 Price Drop
  • IT
  • Current Affairs
  • Tech News

Vivo X200: जाने कितनी कम कीमत पर मिल रहा ये 9400 मिडिया टेक प्रोसेसर वाला स्मार्टफोन

examhopeinfo@gmail.com December 23, 2025 0
Samsung Galaxy S25 Plus
  • IT
  • Current Affairs
  • Tech News

Samsung Galaxy S25 Plus पर मिल रही भारी छूट ,जाने सेल प्राइस

examhopeinfo@gmail.com December 22, 2025 0
Electricity bill saving Smart Plug
  • IT
  • Current Affairs
  • Tech News

AI के इस ज़माने में कैसे बिजली बचा रहे हैं यह स्मार्ट प्लग?

examhopeinfo@gmail.com December 21, 2025 0
Ghost Pairing Scam on Whatsapp
  • IT
  • Current Affairs
  • Tech News

क्या है यह GhostPairing Scam और बिना पासवर्ड और सिम के क्यों हो रहा है व्हाट्सप्प अकाउंट हैक

examhopeinfo@gmail.com December 21, 2025 0
Copyright © All rights reserved for ExamHope. | MoreNews by AF themes.
Go to mobile version