First page Back Continue Last page Overview Graphics
Recursion
Recursion The ability of a subprogram to call itself
Each recursive solution has at least two cases
- Base case The case to which we have an answer
- General case The case that expresses the solution in terms of a call to itself with a smaller version of the problem
For example, the factorial of a number is defined as the number times the product of all the numbers between itself and 0:
N! = N * (N 1)!