Recursion and backtracking
Recursion
A function calls itself to solve smaller subproblems.
Problems to practice
- Fibonacci
- Factorial
- Tower of Hanoi
- Binary tree traversal
- permutations
- subsets
- combinations
- N-Queens
- Sudoku solver
Backtracking
Try a choice, recurse, then undo if it fails.
Example
Generate all subsets or permutations by exploring choices and removing the last choice when it does not work.
Important considerations
Always have a base case and avoid infinite recursion.
Can you explain it without the notes?
Recursion and backtracking
Use your own words. Explain an example and one limitation before checking the explanation.
Check your explanation
Recursion
Turn this concept into a clear answer.
Practice this conceptAdapted from 14_DSA_MASTER.md · “7. Recursion and backtracking”. Examples are study fragments; framework behavior can depend on your version.