1. Array
Start your learning journey by understanding the most fundamental data structure.
2. Singly Linked List
Learn in-depth the most fundamental data structure in a programmer's life
6. Queue
Learn about the data structure that powers CPU and disk scheduling algorithms
7. Binary Tree
Learn all about the most critical data structure in computer science
What you will learn
How a hash function maps arbitrary keys to a finite codomain and why collisions are unavoidable.
The three properties of a good hash function: uniform distribution, deterministic output, and constant time computation
All four collision resolution strategies: separate chaining, linear probing, quadratic probing, and double hashing
Why deletion needs a DELETED tombstone state in open addressing and what breaks without it
The five hashing patterns: counting, pattern generation, fixed window, variable window, and prefix sum
How to design an LRU cache and a randomised set with constant-time operations
Why this course
Reaching for a hash table on every counting or lookup problem is the right reflex. Explaining what happens when two keys collide, why deletion needs a tombstone slot, or how a poor hash function degrades an O(1) average into an O(N) worst case is what separates the engineers who call dict() from the engineers who could implement one on a whiteboard. Most interviewers know which group they have in front of them within the first minute.
This course rebuilds your understanding of hash tables from the hash function up. You learn the four standard collision resolution strategies, the five hashing patterns that cover almost every hash table interview question, and you finish by designing an LRU cache and a randomised set of your own.
Requirements
The course assumes you can read code in any mainstream language and have a working sense of how an array sits in memory.
- Comfort writing loops, conditionals, and functions in at least one language.
- Familiarity with basic Big-O notation (O(N), O(log N), O(1)).
- A working sense of how arrays and linked lists behave, since both underpin the hash table implementations.
Overview
A hash table is the data structure interviewers expect you to reach for whenever a problem mentions counts, lookups, or duplicates. Every mainstream language ships one: Python's dict, Java's HashMap, C++'s unordered_map, JavaScript's Map, Go's map. They all share the same three internal pieces: an indexed array of slots, a hash function that converts a key into an index, and a collision resolution mechanism that decides where a key goes when another key already lives there.
Representation of a hash table
The course covers both halves of the problem: how the data structure actually works under the hood, and how to recognise which of the five standard patterns a given problem fits.
Fundamentals
The course opens with the problem hash tables exist to solve. You see why storing key-value mappings in two parallel arrays forces an O(N) linear scan on every lookup, and how introducing an indexed bucket array with a hash function collapses that lookup to average O(1). From there you study the hash function itself as a mathematical map, and you compare four concrete families: identity, trivial digit extraction, division by modulus, and mid square. Each one is evaluated against the three properties of a good hash function: uniform distribution, deterministic output, and constant-time computation.
The middle of the course is the collision resolution material most resources skip. You implement four strategies in turn: separate chaining with a doubly linked list per bucket, then linear probing, quadratic probing, and double hashing as three flavours of open addressing. For each strategy the course walks the same three operations - search, insert, and delete - so the differences between primary clustering, secondary clustering, and probe-step variation become concrete instead of abstract. You also learn why open addressing needs an EMPTY, DELETED, OCCUPIED slot-state machine and why a missing tombstone silently breaks search.
The fundamentals close with load factor and resize behaviour, so you can explain why the average in "average O(1)" is doing real work, and what determines whether a given table degenerates into a long chain or a long probe.
Problem solving
After the fundamentals, the rest of the course is patterns. Most hash table problems you will see in an interview reduce to one of five templates. Read the problem, name the template, and the choice of key, value, and update step becomes the only remaining decision.
Each pattern is taught in three layers. An Understanding lesson explains the technique on a problem where the pattern is obvious. An Identifying lesson teaches you the wording in a problem that flags it as a counting, window, or prefix-sum question before you start coding. Then four to five problems give you progressively harder applications. The course finishes with two design capstones: an LRU cache built on a hash table backed by a doubly linked list, and a randomised set with O(1) insert, remove, and uniform random access. By the end you can both use a hash table and build one.
How this course is different
Most hash table material on the internet either skips the collision strategies or skips the patterns. This course gives both equal weight.
dict works.EMPTY, DELETED, OCCUPIED slot states.Who this course is for
The course suits anyone who needs to actually understand hash tables rather than just type dict() and hope.
- New programmers who have used a hash map but never thought about what happens on a collision.
- Self-taught and bootcamp graduates who can solve a counting problem but stall when the key has to be derived from the input.
- Working developers who use
HashMaporunordered_mapdaily but cannot explain why average O(1) can degrade to O(N). - Engineers preparing for FAANG and Big Tech interviews where LRU cache, anagram clustering, and subarray-sum questions appear in nearly every onsite.
- Returning engineers who learned hashing years ago and want a refresher that covers all four collision strategies side by side.
- Anyone who has been asked "implement a hash table" in a real interview and wants to walk in with a complete answer instead of a hand wave.
Continue your DSA journey
Hash tables sit at the centre of the DSA curriculum because they show up inside almost every other pattern. After this course, the natural next steps depend on what you want to deepen.
- Array: The hash table is built on top of an array, and several of the patterns in this course (fixed window, variable window, prefix sum) are array patterns where the hash table is the auxiliary structure. Working through the array course makes the underlying mechanics second nature.
- Singly linked list: Separate chaining uses a linked list per bucket, and the LRU cache capstone is a hash table glued to a doubly linked list. The linked list course makes both implementations cleaner.
- Heap: Several frequency-based interview questions ("top k most frequent") combine a hash table for counting with a heap for the top-k step. The two structures are commonly paired in onsites.
- Sorting: Many hash table problems have a sorting alternative that trades O(N) time and O(N) space for O(N log N) time and O(1) space. Knowing both options lets you choose the right one under interview constraints.
- Dynamic programming: DP problems often use a hash table for memoisation when the state space is sparse or non-integer. The prefix sum pattern in this course is also a stepping stone to DP-style state caching.
- Bit manipulation: Bitmasks are essentially compact hash sets when the key space is bounded. Several pattern-generation and counting problems have a bitmask variant that runs faster in practice.
Frequently asked questions
dict in Python, HashMap in Java, and unordered_map in C++ map onto the same internal machinery.for loop in any language and read Big-O notation like O(N), you have everything you need. A basic familiarity with arrays helps but is not required.EMPTY or DELETED slot. Chaining handles high load factors gracefully but has worse cache locality. Linear probing has excellent cache behaviour but degrades sharply once the load factor passes around 0.7, and it suffers from primary clustering where long runs of occupied slots make probes longer for everyone.HashMap, Python's dict, C++'s unordered_map). A hash set stores keys only, with no associated value (Java's HashSet, Python's set, C++'s unordered_set). All four sit on the same engine, the only difference is whether each slot stores a key on its own or a key plus a value.