#recursion
9 articles
Recursion: Thinking in Smaller Selves
Recursion from first principles — base case, recursive case, and the call stack — the mental model you need before trees, graphs, and DP.
Dynamic Programming for Beginners
Dynamic programming demystified — learn how overlapping subproblems and optimal substructure turn exponential brute-force recursion into clean O(n) solutions, starting from Fibonacci.
Binary Trees and Traversals
Master binary tree traversal — inorder, preorder, postorder, and level-order — and the recursive mindset that makes dozens of tree problems click instantly.
Binary Search Trees
The left<node<right invariant gives you O(log n) search, insert, and delete — until the tree degenerates into a linked list. Here's the full picture, including why inorder traversal is a free sort.
Subsets, Permutations & Combinations
Generate subsets, permutations, and combinations with one choose/explore/un-choose backtracking template — and know exactly where 2^n and n! hit the wall.
Divide & Conquer
Split, solve, combine: divide and conquer through merge sort, quickselect, and counting inversions — plus the master theorem and when an O(n) loop wins.
DFS Patterns
Depth-first search is the backbone of cycle detection, flood fill, path enumeration, and clone graph — master the visited-set template, the 3-color trick, and when to reach for DFS over BFS.
Dynamic Programming: The Real Guide
Dynamic programming is a four-step framework for turning exponential recursion into polynomial solutions — master it once and every DP problem opens up.
Backtracking
Master the backtracking algorithm: the choose-explore-unchoose template, pruning that actually matters, and worked subsets, permutations, and N-queens.