Java Reference
In-Depth Information
4 . A recursive algorithm solves a problem by reducing it to smaller versions of
itself.
5 . Every recursive algorithm has one or more base cases.
6 . The solution to a problem in a base case is obtained directly.
7 . A method is recursive if it calls itself.
8 . Recursive algorithms are implemented using recursive methods.
9 . Every recursive method must have one or more base cases.
10 . The general solution breaks a problem into smaller versions of itself.
11 . The general case must eventually be reduced to a base case.
12 . The base case stops the recursion.
13 . While tracing a recursive method:
a. Logically, you can think of a recursive method as having unlimited
copies of itself.
b. Every call to a recursive method—that is, every recursive call—has its
own code and its own set of parameters and local variables.
c. After completing a particular recursive call, control goes back to the
calling environment, which is the previous call. The current (recursive)
call must execute completely before control goes back to the previous
call. The execution in the previous call continues from the point
immediately following the recursive call.
14 . A method is directly recursive if it calls itself.
15 . A method that calls another method and eventually results in the original
method call is indirectly recursive.
16 . A recursive method in which the last statement executed is the recursive
call is called a tail recursive method.
17 . To design a recursive method, you must do the following:
a. Understand the problem requirements.
b. Determine the limiting conditions.
c.
Identify the base cases and provide a direct solution to each base case.
Identify the general case(s) and provide a solution to each general case
in terms of a smaller version of itself.
d.
1
3
EXERCISES
1. Mark the following statements as true or false.
a. Every recursive definition must have one or more base cases.
b. Every recursive method must have one or more base cases.
c. The general case stops the recursion.
 
Search WWH ::




Custom Search