Algorithmic Paradigms — Overview
Phase 2 — Algorithmic Paradigms (Days 13-22)
Goal: Master the seven strategies that solve most interview problems. Each module is a way of thinking about a problem, applied across the data structures from Phase 1.
Pre-req: Phase 1 (foundation data structures). You'll be using arrays, lists, trees, and graphs as the substrate for every paradigm here.
What You'll Cover
| # | Module | Days | The strategy |
|---|---|---|---|
| 2.1 | Sorting & Searching | 13-14 | Binary search + binary search on the answer (Koko, Split Array). The latter is the single biggest interview unlock here. |
| 2.2 | Two Pointers | 15 | Opposite-direction (sorted pair search), same-direction (in-place dedup, move zeros), fast-slow (cycle detection). |
| 2.3 | Sliding Window | 16 | Fixed and variable windows. The "expand right, shrink left" template solves a huge class of substring/subarray problems. |
| 2.4 | BFS & DFS | 17-18 | When to use BFS vs DFS. Multi-source BFS for "from every X simultaneously." |
| 2.5 | Backtracking | 19 | Subsets, permutations, combinations, palindrome partitioning, N-Queens. The "include / exclude" template. |
| 2.6 | Greedy | 20 | Jump Game, Gas Station, interval scheduling. When to not use DP. |
| 2.7 | Dynamic Programming | 21-22 | The hardest module. Recursive → memoized → tabulated → space-optimised. The DAG-of-subproblems mental model. |
The Mental Model
A paradigm is the answer to "what shape is the search space?":
| Search space shape | Paradigm |
|---|---|
| Linear, sorted | Binary Search |
| Linear, find pair/window | Two Pointers / Sliding Window |
| Tree / Graph, all reachable | DFS or BFS |
| Tree / Graph, all combinations | Backtracking |
| Tree / Graph, optimal path with cumulative cost + overlapping subproblems | Dynamic Programming |
| Sequential decisions where local-optimal = global-optimal | Greedy |
Read this table whenever you're stuck on "what approach should I even try?"
How DP Differs From Everything Else
Phase 2 saves DP for last for a reason: it requires you to be fluent with all of recursion, base cases, memoization, and table construction simultaneously. The Climbing Stairs solution file walks you through the recursive → memoized → tabulated → space-optimised progression in one place — re-read it before every DP problem until the four steps feel automatic.
External Resources (Hand-Picked Supplements)
For Dynamic Programming specifically
- MIT 6.006 Spring 2020 — Lecture 15: DP I (SRTBOT) — the most rigorous free DP framework. Read the lecture notes (PDF) before tackling Day 21. The SRTBOT acronym (Subproblems → Relate → Topological order → Base cases → Original problem → Time) becomes your DP debugger.
- freeCodeCamp — Dynamic Programming for Beginners (5h, Alvin Zablan) — paired memoization → tabulation walkthroughs for 10 classic problems. Watch alongside Days 21-22.
For the rest of Phase 2
- Visualgo — Sorting / Graph Traversal — animated comparators showing why Quick / Merge / Heap sort behave differently. Use during sorting & searching and BFS/DFS modules.
- NeetCode — Backtracking Roadmap — clearest free explanation of when subset / permutation / combination backtracking applies, with template walkthroughs.
- Errichto — Binary Search The Right Way (YouTube) — 30-minute video that teaches "binary search on the answer space" properly. Watch before tackling Koko, Split Array Largest Sum, Median of Two Sorted Arrays.