This preview shows pages 1–5. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
For some problems, it’s useful to have a method call
itself.
Known as a
recursive method
.
Can call itself either directly or indirectly through another
method.
Figure 18.1 summarizes the recursion examples and
exercises in this book.
When a recursive method is called to solve a problem, it actually
is capable of solving only the simplest case(s), or
base case(s)
.
If the method is called with a base case, it returns a result.
If the method is called with a more complex problem, it typically
divides the problem into two conceptual pieces
a piece that the method knows how to do and
a piece that it does not know how to do.
To make recursion feasible, the latter piece must resemble the
original problem, but be a slightly simpler or smaller version of
it.
Because this new problem looks like the original problem, the
method calls a fresh copy of itself to work on the smaller
problem
this is a
recursive call
also called the
recursion step
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
The recursion step normally includes a
This is the end of the preview. Sign up
to
access the rest of the document.
This note was uploaded on 11/06/2010 for the course CS 2050 taught by Professor Uhlmann during the Fall '09 term at Missouri (Mizzou).
 Fall '09
 UHLMANN
 Recursion

Click to edit the document details