Java Reference
In-Depth Information
Chapter 13
1. a. True; b. True; c. False; d. False; e. False
3. The case in which the solution is defined in terms of smaller versions of itself.
5. A method that calls another method and eventually results in the original method
call is said to be indirectly recursive.
7.
a. The statements in Lines 2 and 3.
b. The statements in Lines 4 and 5.
c. Any nonnegative integer.
d.
It is a valid call. The value of mystery(0) is 0 .
e.
It is a valid call. The value of mystery(5) is 15 .
f.
It is an invalid call. It will result in the infinite recursion.
9.
a. It does not produce any output.
b. 5 6 7 8 9
c.
It does not produce any output.
d.
It does not produce any output.
11.
a. Go Go Go Go Go Go Stop! b. Go Go Stop!
c. Infinite loop, continuously printing Go .
13.
a. 2
b. 3
c. 5
d. 21
8
<
:
0
if n ¼ 0
15. multiplyðm; nÞ¼
m
if n ¼ 1
m þ multiplyðm; n 1 Þ
otherwise
Chapter 14
1.
a. False; b. True; c. False;
3.
a.
public static int seqOrderedSearch( int [] list, int listLength,
int searchItem)
{
int loc;
bool found = false ;
for (loc = 0; loc < listLength; loc++)
 
 
 
Search WWH ::




Custom Search