Recursion solves a problem by solving a smaller version of the same problem. A recursive function needs two things: a base case that stops the calls, and a recursive case that moves closer to it. Behind the scenes, every call is placed on the call stack, and when the base case returns, the waiting calls finish one by one in reverse order. Trees, graphs, divide and conquer and dynamic programming all build on this idea.
This module starts with how recursion works: base cases, stack frames, and what happens when a function never reaches its base case. It then introduces backtracking, a recursive search that builds a solution one choice at a time and undoes a choice when it leads to a dead end.
The second half is about the pattern itself. Backtracking follows a simple rhythm: choose, explore, unchoose. Subsets show it with an include-or-skip decision at every element, and permutations show it with a choice of which unused element comes next. Watch the lessons in order, then continue on to Sorting & Searching.
The mental model behind recursion: base cases and the call stack followed frame by frame, so you can see exactly how calls build up and unwind.
Backtracking as an idea rather than a template to memorize: why trying a choice, exploring, and undoing it finds every valid solution.
Generate the power set of an array with recursive backtracking, deciding to include or skip each element, with the decision tree drawn out.
Backtracking applied to permutations: pick an unused element, recurse on what is left, and undo the choice to try the next one.