Hashing
Hashing: Hash Maps, Sets and Collisions
The hash map is the most-used data structure in coding interviews and the least-understood. "It is O(1)" is where most explanations stop, which leaves the two questions interviewers actually ask — why is it only average-case, and what happens on collision — without an answer.
These lessons open the structure up. You watch keys hash to buckets, watch collisions occur and get resolved, and see why the average case degrades. Frequency counting is covered as its own lesson because it is the single most common application of hashing in interview problems.
Interactive lessons
Languages (JS, TS, Python, Java, C, C++)
Hashing lessons
Hashing time and space complexity compared
Best, average and worst-case running time and extra space for every hashing lesson, as each lesson derives them.
| Lesson | Best | Average | Worst | Space |
|---|---|---|---|---|
| Hash Map | O(1) | O(1) | O(N) (High Collisions) | O(N) |
| Hash Set | O(1) | O(1) | O(N) (High Collisions) | O(N) |
| Frequency Table | O(N) | O(N) | O(N) | O(K) (Unique Elements) |
| Perfect Hashing | O(1) | O(1) | O(1) | O(N) |
Continue the DSA curriculum
Hashing is one of 12 topics in the interactive DSA visualizer curriculum. Once this topic is comfortable, the coding interview pattern library reorganises the same material around the patterns interview questions are built on.
Every other DSA visualizer
Data Structures · 28 lessons
- StackFree
- QueueFree
- Deque
- Circular Queue
- Priority Queue (ADT)
- Tree Traversal
- Binary Tree
- Binary Search Tree
- AVL Tree
- Trie (Prefix Tree)
- Segment Tree
- Fenwick Tree
- Red-Black Tree
- Singly Linked List
- Doubly Linked List
- Circular Linked List
- Graph RepresentationFree
- Breadth First SearchFree
- Depth First Search
- Topological Sort
- Cycle Detection
- Connected Components
- Bipartite Graph
- Dijkstra's Algorithm
- Bellman-Ford Algorithm
- Minimum Spanning Tree
- Floyd-Warshall Algorithm
- Bridges & Articulation Points
