Skip to content

Algorithms ​

Part of the Interview Prep Roadmap. Coverage ratings are explained there.

Work through alongside this section

  • NeetCode 150 — its binary search, backtracking, dynamic programming, greedy, and graph sections cover most of the topics below. Worth finishing as a whole rather than cherry-picking.
  • CP Algorithms — reference implementations and proofs for the graph and DP algorithms here.

Complexity Analysis ​

Measuring and comparing the cost of an algorithm — the vocabulary every other topic in this phase depends on.

Coverage: moderate

Resources · Big-O Cheat Sheet — complexities of every common structure and algorithm in one table

Asymptotic Notation ​

  • Big-O, Big-Θ, and Big-Ω
  • Best, average, and worst case
  • Growth rate comparison

Practice

Analyzing Code ​

  • Loops and nested loops
  • Recursive calls
  • Recurrence relations and the Master theorem

Practice

Trade-offs ​

  • Time vs. space
  • Amortized analysis

Practice

Sorting & Searching ​

How the common sorting algorithms work and their time complexity, then binary search and its less obvious applications.

Coverage: moderate

Resources · VisuAlgo — sorting — watch each algorithm run step by step · NeetCode — Binary Search

Elementary Sorting ​

  • Bubble sort
  • Selection sort
  • Insertion sort

Practice

Efficient Sorting ​

  • Merge sort
  • Quick sort and pivot selection
  • Heap sort
  • Worst-case behavior of each

Practice

Non-Comparison Sorting ​

  • Counting sort
  • Radix sort
  • Bucket sort
  • Lower bound on comparison-based sorting

Practice

Sorting Properties ​

  • Stability
  • In-place vs. out-of-place
  • Choosing a sort for a given constraint

Practice

Searching ​

  • Linear search
  • Binary search on a sorted array
  • Binary search on an answer space
  • Search in rotated arrays

Practice

Recursion & Backtracking ​

Breaking a problem into itself, and backtracking when a branch doesn't work out.

Coverage: moderate

Resources · NeetCode — Backtracking

Recursion Fundamentals ​

  • Base case and recursive case
  • The call stack and stack depth
  • Recursion vs. iteration
  • Tail recursion

Practice

Recursive Patterns ​

  • Divide and conquer
  • Tree and graph recursion
  • Subsets and permutations

Practice

Backtracking ​

  • State-space exploration
  • Pruning invalid branches
  • Classic problems: N-Queens, Sudoku, word search
  • Complexity of backtracking

Practice

Dynamic Programming ​

What makes a problem a DP problem — overlapping subproblems and optimal substructure — then memoization vs. tabulation.

Coverage: moderate

Resources · NeetCode — 1-D and 2-D DP · CP Algorithms — DP

DP Fundamentals ​

  • Overlapping subproblems
  • Optimal substructure
  • Recognizing a DP problem

Practice

Implementation Approaches ​

  • Top-down memoization
  • Bottom-up tabulation
  • Space optimization

Practice

Classic DP Patterns ​

  • 1D DP: Fibonacci, climbing stairs, house robber
  • Knapsack variants
  • Subsequence problems: LCS, LIS
  • Grid and path-counting problems
  • Partition and subset-sum problems

Practice

Greedy Algorithms ​

Making the locally optimal choice at each step, and knowing when that actually yields a globally optimal answer.

Coverage: thin

Resources · NeetCode — Greedy

Greedy Fundamentals ​

  • Greedy-choice property
  • Cases where greedy fails
  • Greedy vs. dynamic programming

Practice

Classic Greedy Problems ​

  • Activity selection and interval scheduling
  • Fractional knapsack
  • Huffman coding
  • Coin change

Practice

Graph Algorithms ​

BFS and DFS as the foundation, then Dijkstra, Bellman-Ford, and MST — which algorithm fits which constraint, and why.

Coverage: rich

Resources · CP Algorithms — graph algorithms — reference implementations and proofs · VisuAlgo — graph traversal

Traversal ​

  • Breadth-first search
  • Depth-first search
  • Visited tracking and traversal order
  • Finding connected components

Practice

Shortest Path ​

  • BFS for unweighted graphs
  • Dijkstra's algorithm
  • Bellman-Ford and negative weights
  • Floyd-Warshall for all pairs

Practice

Minimum Spanning Tree ​

  • Kruskal's algorithm
  • Prim's algorithm
  • Union-find (disjoint set union)

Practice

Ordering & Structure ​

  • Topological sort
  • Cycle detection in directed and undirected graphs
  • Strongly connected components

Practice

Bit Manipulation ​

Basic bitwise operations and shifting, then bitmasking and common XOR tricks.

Coverage: thin

Resources · Bit Twiddling Hacks — the canonical collection

Bitwise Operators ​

  • AND, OR, NOT, XOR
  • Left and right shift
  • Signed vs. unsigned shifts

Practice

Bit Tricks ​

  • Checking, setting, clearing, and toggling a bit
  • Counting set bits
  • Powers of two
  • XOR properties for finding unique elements

Practice

Bitmasking ​

  • Representing subsets as bitmasks
  • Iterating over subsets
  • Bitmask DP