Chapter 12 Flashcards

1
Q

Recursion is a

A

Problem-solving method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Recursion is often used when a problem’s solution relies on a

A

Simpler solution to the same problem

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

A recursive method is a method that

A

Calls itself

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

A recursive method

A

Might contain any number of statements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

a useful recursive method must

A

Provide a way to stop recursion

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

The approach to writing nonrecursive methods that include loops to produce results is

A

Iterative

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Programmer might choose an iterative approach to a problem rather than a recursive one because iterative programs often

A

Run more quickly

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

The excess computation time required for repeated method calls in recursive programs is called

A

Overhead

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

When you use recursion, you frequently ask a method to call itself repeatedly

A

Using a simpler version of the problem each time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

When a method calls another method, the location to return to when the second method finishes is stored in the

A

Call stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

In a recursive method, there typically are

A

More recursive cases than base cases

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

The case in a recursive method that does not make a recursive call is the

A

Base case

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

The cases in a recursive method that make recursive calls are the

A

Recursive cases

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

The factorial of a nonnegative integer is the ________ of all the integers from 1 up to and including the integer.

A

Product

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Computing factorials lends itself to recursion because

A

Computing the factorial of any number relies on computing the factorial of a simpler case

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

In a recursive method, the case in which no recursive call is needed is the

A

Base case

17
Q

After using the statement p = n.indexOf(‘A’); if p contains 5, then

A

There is an ‘A’ in string n

18
Q

Recursion can be successfully used to

A

Solve mathematical problems and to create visual patterns

19
Q

Recursive approach can be used to

A

Display characters on consecutive lines where each is one space further to the right than the previous one

20
Q

You can substitute a recursive solution to a problem for an iterative one

A

Only if the iterative solution contains at least one if statement