#recursion
9 articles
Recursion: Thinking in Smaller Selves
Recursion explained from first principles — base case, recursive case, the call stack, and why your function sometimes blows up. The mental model every programmer needs before touching trees, graphs, or dynamic programming.
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 every subset, permutation, and combination with the choose/explore/un-choose backtracking template. Understand the 2^n and n! complexity ceilings, why sorting kills duplicate branches, and how to recognize which variant a problem is actually asking for.
Divide & Conquer
Split a problem into smaller subproblems, solve them independently, combine the results. This one mental model gives you merge sort, quickselect, the count-inversions trick, and Kadane's origin story — plus the intuition for why n log n is the price of sorting.
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 isn't about memorizing patterns — it's a four-step framework for turning exponential recursion into linear solutions. Master the mental model once and every DP problem opens up.
Backtracking
Learn the backtracking algorithm pattern — the systematic brute force that prunes itself. Master the universal choose-explore-unchoose template and apply it to subsets, permutations, combination sum, and N-queens.