Lecture 14 (Edwards) - Methods and Recursion

Lecture Date: Wednesday, March 4

Today we will continue our discussion on methods and talk about a special type of method, recursive methods.

We will also talk about the stack and what to watch out for when doing recursive methods.

Recursion

Colbert

When writing a recursive method you always need to keep in mind 3 things:

  1. Recursive Case: under some condition it invokes itself.

  2. Base Case: under some condition it does not invoke itself.

  3. Progress: each time it invokes itself it gets closer to the base case.

We will do a few examples and then get ready for Spring Break!

If you want extra practice check out codingbat.com/java;

Code from class: