Article series · 12 lessons
Data structure foundations
Build a vocabulary of arrays, trees, heaps and graphs, with their costs and invariants.
Follow the sequence below, or pick up where you left off. Nothing is locked.
What you’ll work toward & your progress
What you’ll work toward
- Corrected the two-pointer elimination proof: nums[left] is the smallest remaining partner for nums[right]
- MiniHashMap now validates power-of-two capacity and searches past a tombstone for an existing key before reusing it; otherwise updating a colliding key can create duplicates
- Linked-list operations assume acyclic disjoint lists except explicit cycle tests and require valid removal positions
- Deque front removal is approximately O(1); list append/pop at the end are amortized where resize applies
Completion is stored on this device only. Nothing is locked; start where it makes sense.
Before the first lesson
These are the starting lesson’s prerequisites, not requirements for every advanced topic below.
How to practise this subject
Draw the structure before and after an update. Check empty, singleton and repeated-value cases, and account separately for time, auxiliary storage and the returned result.
Lessons in order
- 01
Arrays & Strings — Indexing, Slicing, Two-Pointer
Apply indexing, slicing, compaction and two-pointer methods with explicit ordering, mutation, Unicode and complexity contracts.
- 02
Hashmaps & Sets — Hash Functions, Collisions
Derive hash-table lookup and collision behavior, stable hash/equality contracts, ordering limits and explicit expected versus worst-case costs.
- 03
Linked Lists — Singly, Doubly, When They Win
The data structure reviewers still love — plus the three real-world situations where a linked list actually beats an array.
- 04
Stacks & Queues — LIFO/FIFO in Practice
Apply LIFO and FIFO invariants to traversal, monotonic structures and bounded queues; distinguish local ordering from distributed guarantees.
- 05
Recursion — Call Stack, Base Case, Worked Examples
Trace recursive calls and base cases, account for memo and stack resources, and compare equivalent iterative implementations.
- 06
Trees & BSTs — Traversal (BFS/DFS)
Trace tree traversal and BST invariants with explicit height, ordering, duplicate, node-identity and range-output contracts.
- 07
Heaps & Priority Queues
Apply heap invariants to top-K, merging, medians and weighted paths while accounting for ties, storage and update costs.
- 08
Graphs — Representation, BFS, DFS, Shortest Path
Represent graphs and derive traversal, connectivity and shortest-path algorithms under explicit vertex, ordering and edge-weight contracts.
- 09
Sorting — Merge, Quick, and When to Trust the Built-in
Compare merge, quick and heap sorting with explicit stability, comparator, storage and worst-case contracts, including when to use Python built-ins.
- 10
Binary Search — the Pattern Behind 100 Problems
Derive exact search, insertion boundaries and binary search on a monotone answer predicate, with shrinking-interval proofs, shipping-capacity witnesses and explicit cost assumptions.
- 11
Dynamic Programming — Memoisation & Tabulation
Define states, transitions, base cases and evaluation order; derive time and storage from the actual state space rather than assuming polynomial complexity.
- 12
Greedy & Backtracking — When to Use Each
Prove greedy choices for the precise objective, and build complete backtracking searches with correct undo, sound pruning and explicit output costs.