Backtracking & Recursion
Master the art of systematic search through decision trees. Learn recursive thinking, backtracking templates, pruning strategies, and memoization — all with complete Python solutions progressing from brute force to optimal. These patterns power search algorithms in AI planning, constraint satisfaction, and hyperparameter tuning.
Your Learning Path
Follow these lessons in order, or jump to any topic that interests you.
1. Recursion & Backtracking Fundamentals
Recursion mechanics, call stack visualization, the backtracking template, and how these patterns appear in AI search and ML hyperparameter tuning.
2. Permutations & Combinations
5 problems: permutations, permutations II, combinations, combination sum, letter case permutation. Brute force to optimal with pruning.
3. Subset Problems
5 problems: subsets, subsets II, combination sum, combination sum II, partition to K equal subsets. Include/exclude decision trees.
4. Grid & Matrix Backtracking
5 problems: word search, N-queens, Sudoku solver, rat in a maze, unique paths with obstacles. 2D constraint satisfaction.
5. String Backtracking
5 problems: palindrome partitioning, generate parentheses, letter combinations of phone number, restore IP addresses, word break II.
6. Pruning & Optimization
Pruning techniques, memoization with backtracking, branch and bound, and converting exponential search into polynomial solutions.
7. Patterns & Tips
Reusable template code for every backtracking variant, a decision framework for choosing the right approach, and an FAQ accordion.
What You'll Learn
By the end of this course, you will be able to:
Think Recursively
Break any problem into smaller subproblems, identify base cases, and build solutions by combining recursive results.
Apply Backtracking Templates
Use a universal backtracking template to solve permutation, subset, constraint satisfaction, and grid search problems.
Optimize with Pruning
Cut exponential search spaces with constraint propagation, symmetry breaking, memoization, and branch-and-bound techniques.
Connect to ML Systems
Understand how backtracking powers AI planning, constraint solvers, hyperparameter search, and neural architecture search.
Lilly Tech Systems