Algorithms Overview
Guides to algorithms and data structures. Topics are ordered by learning priority (easy + high ROI first).
- Data structures — Structures that appear across these topics
- Time & space complexity — Big O reference and summary table for these topics
- Two Pointers — Two indices moving through a sequence
- Sliding Window — Fixed or variable window over a sequence
- Prefix Sum — Precompute cumulative sums for O(1) range queries
- Breadth-First Search — Level-by-level graph or tree traversal
- Depth-First Search — Explore as far as possible along each branch
- Binary Search — Halve the search space on each step
- Heap — Priority queue and min/max-heap operations
- Backtracking — Try choices, recurse, undo on dead ends
- Dynamic Programming — Reuse subproblem results (memoization or tabulation)
- Divide and Conquer — Split, solve subproblems, combine
- Trie — Prefix tree for strings and prefix lookups
- Union Find — Disjoint set union for connectivity
- Greedy — Make locally best choices at each step
Typical Input Types
Section titled “Typical Input Types”Algorithm problems often take one or more of these input shapes; recognizing them helps you choose the right technique. Input types here mean the form of the problem input (what you’re given). Data structures include both those forms and the structures we use while solving (e.g. stacks, heaps, hash maps). For the full picture of structures and where they appear, see Data structures.
- Scalars — Single numbers (e.g.
n,k,target). - Arrays / lists — Sequences of numbers or objects (e.g.
arr,nums,intervals). - Strings — Text (e.g.
s,text); sometimes treated as a sequence of characters. - Graphs — Usually given as an edge list (pairs or triplets), adjacency list (e.g. dict or list of neighbors), or adjacency matrix; often for undirected or directed graphs.
- Trees — Often represented like graphs (e.g. adjacency list or parent pointers) or in an array form (e.g. heap).
- Matrix / grid — 2D array (e.g. for grids, images).
- Stream / online — Input arrives over time (e.g. dynamic connectivity).
Other Common Names
Section titled “Other Common Names”| Algorithm | Other common names |
|---|---|
| Two Pointers | Two-pointer technique, dual pointers |
| Sliding Window | Fixed-size / variable-size window (when distinguishing) |
| Prefix Sum | Cumulative sum, running sum, scan |
| Breadth-First Search | BFS, level-order traversal (on trees) |
| Depth-First Search | DFS, depth-first traversal |
| Binary Search | Binary search on the answer (for search-space use) |
| Heap | Priority queue (abstract), binary heap, min-heap / max-heap |
| Backtracking | Recursive backtracking, DFS + undo |
| Dynamic Programming | DP, memoization (top-down + cache) |
| Divide and Conquer | D&C, recursive divide; merge sort, quicksort; insertion sort (baseline) |
| Trie | Prefix tree, digital tree, radix tree (when compressed) |
| Union Find | Disjoint Set Union (DSU), disjoint sets, merge-find |
| Greedy | Greedy algorithm, myopic strategy |
Suggested Order (by Learning Priority)
Section titled “Suggested Order (by Learning Priority)”| order | Title | Difficulty | ROI |
|---|---|---|---|
| 1 | Two Pointers | Easy | High |
| 2 | Sliding Window | Easy | High |
| 3 | Prefix Sum | Easy | High |
| 4 | Breadth-First Search | Easy | High |
| 5 | Depth-First Search | Medium | High |
| 6 | Binary Search | Easy | Medium |
| 7 | Heap | Medium | Medium |
| 8 | Backtracking | High | High |
| 9 | Dynamic Programming | High | Medium |
| 10 | Divide and Conquer | Medium | Low |
| 11 | Trie | Medium | Low |
| 12 | Union Find | Medium | Low |
| 13 | Greedy | High | Low |