• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 14 pages
Class notes

Hashing in Data Structures | Hash Functions, Open Addressing & Chaining — Complete DSA Notes

Document preview thumbnail
Preview 2 out of 14 pages

Complete and easy-to-understand study notes on Hashing in Data Structures and Algorithms (DSA). These notes provide a detailed explanation of Hashing, Hash Functions, Open Addressing, and Overflow Handling using Chaining. They are designed to help students understand important hashing concepts and prepare for exams, assignments, and quick revision. Topics Covered: Introduction to Hashing Hash Tables Hash Functions How Hash Functions Work Hashing Techniques Collisions in Hashing Collision Resolution Open Addressing Overflow Handling Chaining / Separate Chaining Important Hashing Concepts Perfect for: BSCS & BSIT students Computer Science students DSA learners University exam preparation Programming students Quick revision Assignments and study preparation A structured and student-friendly set of DSA notes covering the key concepts of Hashing in one place.

Content preview

Hashing Hash Functions · Open Addressing · Chaining




Hashing in Data Structures
Hash Functions · Open Addressing · Overflow Handling (Chaining)


1. Introduction to Hashing
Hashing is a technique in which we convert a piece of data (key) directly into an
array index (address) so that data can be stored and retrieved very quickly in
constant time O(1).


Hashing is a data structure technique used to store and retrieve data in constant average time O(1).
It is widely used in:
• Databases (fast searching)
• Compilers (symbol tables)
• Caches (CPU memory)
• Dictionaries (key-value mapping)

Example: Imagine you have a library with many books. Each book has a unique ID number.

Now you want to find a book:

� Normal method: You check each shelf one by one (slow ❌)
� Hashing method: You directly get the shelf number using a formula and go straight to it (fast ✔)

1.1 Basic Idea
Hashing converts a key (input data) into an index (address in table) using a function called a hash
function.
Example
If key = 45 and table size = 10
45 % 10 = 5
→ Value stored at index 5




BSCS — Hashing in Data Structures | Lecture Notes

, Hashing Hash Functions · Open Addressing · Chaining



DIAGRAM 1 — Hash Table Structure (Visual Memory)
How a hash function maps keys to array indices
KEY (Input)



+-----------------------------------------------------------------------------+
| HASH FUNCTION |
| h(k) = k mod m Here k = key (45) and m = table size (10) |
| |
+-----------------------------------------------------------------------------+



INDEX = h(k)


+----+----+----+----+----+----+----+----+----+----+
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
+----+----+----+----+----+----+----+----+----+----+
| | | | | | 45 | | | | |
+----+----+----+----+----+----+----+----+----+----+



45 % 10 = 5 → stored here

If 25 also inserted: 25 % 10 = 5 → COLLISION!




2. Hash Table Structure
A hash table is an array-based structure where data is stored using indices generated by a hash
function.

2.1 Components
• Key → input value (e.g., student ID)
• Hash Function → converts key into index
• Hash Table → array storing data
• Collision Handling → resolves conflicts



3. Hash Functions
A hash function maps a key to a fixed range of values (table index).

3.1 Characteristics of Good Hash Function
• Fast computation
• Uniform distribution
• Minimum collisions
• Valid index generation



4. Division Method (Most Important Hash Function)

BSCS — Hashing in Data Structures | Lecture Notes

Document information

Uploaded on
October 1, 2026
Number of pages
14
Written in
2026/2027
Type
Class notes
Professor(s)
Zain
Contains
All classes
$3.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Sold
0
Followers
0
Items
43
Last sold
-




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions