12.1: Recursion Basics
( \newcommand{\kernel}{\mathrm{null}\,}\)
By the end of this section you should be able to
- Describe the concept of recursion.
- Demonstrate how recursion uses simple solutions to build a better solution.
Recursion
Recursion is a problem solving technique that uses the solution to a simpler version of the problem to solve the bigger problem. In turn, the same technique can be applied to the simpler version.
Move two rings from the source tower to the target tower.
Cannot be solved with recursion.
Recursion to find a complete solution
The recursion process continues until the problem is small enough, at which point the solution is known or can easily be found. The larger solution can then be built systematically by successively building ever larger solutions until the complete problem is solved.
2
3