Chapter 15 Complete Test Bank Recursion - Java Control Structures 7e Test Bank by Tony Gaddis. DOCX document preview.

Chapter 15 Complete Test Bank Recursion

Starting Out with Java: From Control Structures through Objects 7e (Gaddis)

Chapter 15 Recursion

TRUE/FALSE

1. Any problem that can be solved recursively can also be solved iteratively, with a loop.

2. Whereas a recursive algorithm might result in faster execution time, the programmer might be able to design an iterative algorithm faster.

3. The recursive case does not require recursion so it stops the chain of recursive calls.

4. Without a base case, a recursive method will call itself only once and stop.

5. A problem can be solved recursively if it can be broken down into successive smaller problems that are identical to the overall problem.

6. The Towers of Hanoi is a mathematical game that is often used in computer science textbooks to illustrate the power of recursion.

7. A recursive method can have only one base case.

8. The recursive binary search algorithm is a good example of repeatedly breaking a problem down into smaller pieces until it is solved.

9. Recursion is never absolutely required to solve a problem.

10. Recursion can be a powerful tool for solving repetitive problems and is an important topic in upper-level computer science courses.

MULTIPLE CHOICE

1. Which of the following problems can be solved recursively?

a.

greatest common denominator

c.

binary search

b.

Towers of Hanoi

d.

All of these.

2. A method that calls itself is a __________ method.

a.

recursive

b.

redundant

c.

binary

d.

derived

3. A recursive method must have which of the following?

a.

a statement that increments the control variable

b.

a control variable initialized to a starting value

c.

some way to control the number of time it repeats

d.

All of these

4. In a recursive program, the number of times a method calls itself is known as the __________.

a.

call count

c.

method heap

b.

cyclic identity

d.

depth of recursion

5. The actions performed by the JVM that take place with each method call are sometimes referred to as __________.

a.

overhead

b.

allocation

c.

overflow

d.

retention

6. The __________ is at least one case in which a problem can be solved without recursion.

a.

recursive case

c.

termination point

b.

base case

d.

pont of absolution

7. In the __________, the problem must be reduced to a smaller version of the original problem.

a.

partition case

c.

lessening case

b.

base case

d.

recursive case

8. When recursive methods directly call themselves, it is known as __________.

a.

direct recursion

c.

basic recursion

b.

indirect recursion

d.

static recursion

9. __________ occurs when method A calls method B which in turn calls method A.

a.

dynamic recursion

c.

direct recursion

b.

linear recursion

d.

indirect recusion

10. A method is called from the main method for the first time. It then calls itself seven times. What is the depth of recursion?

a.

1

b.

7

c.

8

d.

6

11. To use recursion for a binary search, what is required before the search can proceed?

a.

The array must include only integers.

b.

The array can only include numerical values.

c.

The array must be sorted.

d.

All of these are required.

12. In the following code that uses recursion to find the factorial of a number, what is the base case?

private static int factorial(int n)

{

if (n == 0)

return 1;

else

return n * factorial(n - 1);

}

a.

factorial(int n)

b.

if (n == 0)

return 1;

c.

else

return n * factorial(n - 1);

d.

Cannot tell from this code

13. Given the following code that uses recursion to find the factorial of a number, how many times will the else clause be executed if n = 5?

private static int factorial(int n)

{

if (n == 0)

return 1;

else

return n * factorial(n - 1);

}

a.

3

b.

4

c.

5

d.

6

14. In the following code that uses recursion to find the greatest common divisor of a number, what is the base case?

public static int gcd(int x, int y)

{

if (x % y == 0)

return y;

else

return gcd(y, x % y);

}

a.

gcd(int x, int y)

b.

if (x % y == 0)

return y;

c.

else

return gcd(y, x % y);

d.

Cannot tell from this code

Document Information

Document Type:
DOCX
Chapter Number:
15
Created Date:
Aug 21, 2025
Chapter Name:
Chapter 15 Recursion
Author:
Tony Gaddis

Connected Book

Java Control Structures 7e Test Bank

By Tony Gaddis

Test Bank General
View Product →

$24.99

100% satisfaction guarantee

Buy Full Test Bank

Benefits

Immediately available after payment
Answers are available after payment
ZIP file includes all related files
Files are in Word format (DOCX)
Check the description to see the contents of each ZIP file
We do not share your information with any third party