🗺️Hash Maps from Scratch
Stop using dict, set, and HashMap as black boxes — build one from scratch in fourteen days, see exactly how hashing turns keys into bucket indices, and learn why your map slows to a crawl when load factor crosses 0.75.
Phase 1How Hashing Turns Keys Into Addresses
See how hashing turns any key into a bucket index
A hash map is just a list with a clever index function
6 minA hash map is just a list with a clever index function
A hash function is a deterministic shredder for any input
6 minA hash function is a deterministic shredder for any input
Buckets are slots, and modulo is how you pick one
6 minBuckets are slots, and modulo is how you pick one
Collisions are mathematically guaranteed, not a bug
7 minCollisions are mathematically guaranteed, not a bug
Phase 2Build a Minimal Hash Map by Hand
Build a minimal hash map with put, get, delete
A hash map is a class with one array and a count
5 minA hash map is a class with one array and a count
Put writes to a slot, but first it has to find the right one
7 minPut writes to a slot, but first it has to find the right one
Get walks the chain until it finds your key or runs out
6 minGet walks the chain until it finds your key or runs out
Delete is get with one extra step — splicing the chain
6 minDelete is get with one extra step — splicing the chain
Iteration walks every chain in every bucket
6 minIteration walks every chain in every bucket
Phase 3Chaining vs Open Addressing in Real Code
Choose chaining or open addressing by tradeoff, not habit
Your team's API just slowed 10x — and chaining is the suspect
7 minYour team's API just slowed 10x — and chaining is the suspect
Your map's chains are too cache-unfriendly — what now?
7 minYour map's chains are too cache-unfriendly — what now?
Your map degraded smoothly until load factor 0.85, then fell off a cliff
7 minYour map degraded smoothly until load factor 0.85, then fell off a cliff
The fastest dict in your service spikes to 50ms once an hour — that's a resize
7 minThe fastest dict in your service spikes to 50ms once an hour — that's a resize
Phase 4Ship a Hash Map That Resizes Under Load
Ship a hash map that resizes gracefully under load
Add resize to your hash map and survive a million inserts
8 minAdd resize to your hash map and survive a million inserts
Frequently asked questions
- What is a hash map and how does it actually work?
- This is covered in the “Hash Maps from Scratch” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
- Why is a hash map lookup O(1) on average but O(n) worst case?
- This is covered in the “Hash Maps from Scratch” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
- What is load factor and why does 0.75 matter?
- This is covered in the “Hash Maps from Scratch” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
- What is the difference between chaining and open addressing?
- This is covered in the “Hash Maps from Scratch” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
- When does a hash map resize and why is it expensive?
- This is covered in the “Hash Maps from Scratch” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
Related paths
🐍Python Decorators Introduction
Build one mental model for Python decorators that covers closures, argument passing, functools.wraps, and stacking — then ship a working caching or logging decorator from scratch in under 30 lines.
🦀Rust Lifetimes Explained
Stop reading `'a` as line noise and start reading it as scope arithmetic — one failing snippet at a time — until you can thread lifetimes through a small parser or iterator adapter without fighting the borrow checker.
☸️Kubernetes Core Concepts
Stop drowning in 30+ resource types. Build the mental model one primitive at a time -- pods, deployments, services, ingress, config -- then deploy a real app with rolling updates and health checks.
📈Big O Intuition
Stop treating Big O as math you memorized for an interview — build the intuition to spot O(n²) disasters, pick the right data structure without thinking, and rewrite a slow function from O(n²) to O(n) in under five minutes.