Hashing (Concept & Techniques)- Data Structure
harshclassic07
10 views
20 slides
Sep 16, 2025
Slide 1 of 20
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
About This Presentation
This presentation offers an in-depth exploration of advanced hashing techniques, designed specifically for students with a foundational understanding of data structures and algorithms
Size: 345.11 KB
Language: en
Added: Sep 16, 2025
Slides: 20 pages
Slide Content
Hashing (Concept & Techniques)
What is Hashing? Hashing is a technique that maps data of arbitrary size → fixed-size value (index) using a hash function. Enables fast insertion, search, deletion .
Hashing Techniques A. Open Addressing (In-Table Collisions) Linear Probing: h'(key, i ) = (h(key) + i ) % table_size Quadratic Probing: h'(key, i ) = (h(key) + i^2) % table_size Double Hashing: h'(key, i ) = (h1(key) + i *h2(key)) % table_size B. Chaining Each index holds a linked list of colliding keys. C. Perfect Hashing Maps n keys → n slots without collisions. Ideal for static datasets .
Hash Table Array-like structure using hash function to store keys. Features: Fast operations: O(1) average time Requires collision handling Pseudo Code (Insertion using Chaining):
Hash Function Converts key → index Properties: Fast Uniform Deterministic Common Types: Division: h(key) = key % table_size Multiplication : h(key) = floor( table_size * (key * A % 1)) String Hashing: ASCII sum, polynomial rolling hash
Advantages of Hashing Techniques Fast Access: O(1) average for search, insert, delete Efficient Memory: Optimized storage if table size chosen well Flexible: Can store different types of keys Widely Used: Databases, caching, symbol tables Open Addressing Advantages: Simple structure, no extra memory for linked lists Cache-friendly Easy to implement Perfect Hashing Advantages: No collisions → O(1) search guaranteed Ideal for static datasets
Disadvantages of Hashing Techniques Collisions require handling (chaining or probing) Poor hash function → clustering & uneven distribution Fixed-size table → overflow or need for resizing Cannot maintain sorted order of elements Open addressing: performance degrades with high load factor
Applications of Hashing Database Indexing – fast retrieval of records Symbol Tables – in compilers and interpreters Caching – storing frequently accessed data Password Storage – hashing + salting Cryptography – MD5, SHA algorithms Sets & Maps – key-value pairs in programming languages
Red- Black Tree Self-balancing BST using colors (Red/Black) Properties: Root is black Red nodes cannot have red children Every path from root → leaf has same black height Node Structure:
Rotations Left Right
BST Insertion Red-Black Tree Insertion
Fixing Violations After Insertion
Binomial Heap A Binomial Heap is a collection of Binomial Trees that satisfies the Min-Heap (or Max-Heap) property. Each tree in the heap follows heap-order property (parent ≤ children for min-heap). Efficient for mergeable priority queues . Properties: A Binomial Tree of order k has 2^k nodes . Height of tree = k Number of nodes at depth i = C(k, i ) (binomial coefficient)
Fibonacci Heap A Fibonacci Heap is a collection of heap-ordered trees with a relaxed structure , allowing very fast amortized operations. Optimized for algorithms that require lots of decrease-key operations , like Dijkstra’s algorithm . Properties: Each tree satisfies min-heap property (parent ≤ children). Nodes are linked circularly in a root list Maintains pointer to the minimum node for O(1) access. Lazy consolidation — trees are merged only when necessary.
Array, Structure and Binary List Array : Contiguous elements, random access O(1) Structure : Groups multiple data types Binary List : Efficient 0/1 storage used in sets, bitmap indexing