DBMS Topics
Dynamic Hashing
Last Updated : 21 May, 2026
Static hashing suffers when data size changes unpredictably:
Why Dynamic Hashing?
Static hashing suffers when data size changes unpredictably:
- Too few buckets → overflow chains → slow
- Too many buckets → wasted space
Dynamic hashing allows the hash table to grow and shrink as data changes, maintaining good performance without a fixed bucket count.
Two main forms:
- Extendible Hashing — directory-based, doubles directory on overflow
- Linear Hashing — directory-free, adds one bucket at a time
Extendible Hashing
Concept
Uses a directory (array of pointers to buckets) that can double in size. The key idea is using the first i bits of the hash value to index into the directory.
Structure
| Directory | Buckets: |
| │ 00 │ ─────────┼──────► Bucket A (local depth 2) | [10][14] |
| │ 01 │ ─────────┼──────► Bucket B (local depth 1) | [5][9][13] |
| │ 10 │ ─────────┼──────► Bucket C (local depth 2) | [2][6] |
| └────────────────┘ └──► Bucket D (local depth 2) | [3][7] |
Search in Extendible Hashing
| Example | Global depth = 2, K=6, h(6) = ...10... |
| First 2 bits = "10" | index 2 → Bucket C |
| Search Bucket C for K=6 | Found! |
| Cost | 1 directory read + 1 bucket read |
Insert with Bucket Split
| Case 1 | Local depth j < Global depth i |
| Case 2 | Local depth j = Global depth i |
| Example | Insert into full Bucket A (local depth 2 = global depth 2) |
| Step 1: Double directory: global depth 2 | 3 (4 entries → 8 entries) |
| Step 2 | Split Bucket A into A and A' |
| Step 3 | Redistribute records using 3-bit prefix |
Extendible Hashing Diagram (After Split)
| BEFORE (Global depth 2) | AFTER INSERT (Global depth 3): |
| Dir | Bucket: Dir (8 entries): Bucket: |
| Insert 15 into B (full) | 101 ─► B' [15] |
Linear Hashing
Concept
Linear hashing adds one bucket at a time in a predetermined linear order, without using a directory. It uses a sequence of hash functions.
Linear Hashing Lookup
When to Split
A split is triggered when the load factor exceeds a threshold (e.g., 0.8):
Extendible vs. Linear Hashing
| Feature | Extendible Hash | Linear Hash |
|---|---|---|
| Directory | Yes (doubles) | No (dir-free) |
| Split trigger | Bucket overflow | Load factor |
| Buckets added | One at a time | One at a time |
| Directory overhead | Can double | None |
| Implementation | Moderate | Slightly complex |
| Search cost | 1 dir + 1 bucket | O(1) — 1 bucket |
Dynamic Hashing vs. Static Hashing
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Dynamic Hashing.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this DBMS topic.
Search Terms
dbms, database management system, database notes, sql, unit, dynamic, hashing, dynamic hashing
Related DBMS Topics