Recursive Methods
April 4th, 2016
Recursion
Recursion slides
- The general idea behind recursion is to use the solutions to
problems of size 0 through size n-1 to solve a problem of size n.
- Recursion always involves one or more base cases. A base case
occurs when you immediately know the answer.
- Recursion always involves a general case. The general case of size n
is solved by using solutions to smaller problems.
- A method that calls itself is an example of recursion.
- If method A calls method B and method B calls method A, that
is another example of recursion.
Class Exercises
- Factorial
- Finding the largest item in an array
- Towers of Hanoi - code