Deck 15: Recursion

Full screen (f)
exit full mode
Question
Tracing through ____ recursion is more tedious than tracing other recursive forms.

A) direct
B) indirect
C) tail
D) iterative
Use Space or
up arrow
down arrow
to flip the card.
Question
Infinite recursions execute forever on a computer.
Question
Consider the accompanying definition of a recursive function.What is the output of the following statement? cout << recFunc(10) << endl;

A) 10
B) 11
C) 100
D) 110
Question
You can use a recursive algorithm to find the largest element in an array.
Question
The following is an example of a recursive function.
The following is an example of a recursive function.  <div style=padding-top: 35px>
Question
Consider the following definition of the recursive function print. What is the output of the following statement?
Print(4);
<strong>Consider the following definition of the recursive function print. What is the output of the following statement? Print(4);  </strong> A) 0 1 2 3 4 B) 1 2 3 4 C) 4 3 2 1 D) 4 3 2 1 0 <div style=padding-top: 35px>

A) 0 1 2 3 4
B) 1 2 3 4
C) 4 3 2 1
D) 4 3 2 1 0
Question
Consider the accompanying definition of a recursive function.Which of the statements represents the base case?

A) Statements in Lines 1-6.
B) Statements in Lines 3 and 4.
C) Statements in Lines 5 and 6.
D) Statements in Lines 3, 4, and 5.
Question
A definition in which something is defined in terms of a smaller version of itself is called a(n) ____ definition.

A) step-wise
B) recursive
C) member-wise
D) iterative
Question
Consider the accompanying definition of a recursive function.Which of the statements represent the general case?

A) Statements in Lines 3-11
B) Statements in Lines 5-6
C) Statements in Lines 5-11
D) Statements in Lines 7-11
Question
The following is a valid recursive definition to determine the factorial of a non-negative integer.
The following is a valid recursive definition to determine the factorial of a non-negative integer.  <div style=padding-top: 35px>
Question
In the Tower of Hanoi recursive program, if needle 1 contains three disks, then the number of moves required to move all three disks from needle 1 to needle 3 is 8.
Question
The ____ case is the case for which the solution to an equation is obtained directly.

A) general
B) base
C) direct
D) tail
Question
To design a recursive function, you must determine the limiting conditions.
Question
Consider the accompanying definition of a recursive function.Which of the statements represent the general case?

A) Statements in Lines 1-6
B) Statements in Lines 3 and 4
C) Statements in Lines 4, 5, and 6
D) Statements in Lines 5 and 6
Question
Consider the accompanying definition of a recursive function.Which of the statements represent the base case?

A) Statements in Lines 3 and 4
B) Statements in Lines 5 and 6
C) Statements in Lines 3-6
D) Statements in Lines 5-10
Question
Every call to a recursive function requires the system to allocate memory for the local variables and formal parameters.
Question
With recursion, the base case must eventually be reduced to a general case.
Question
In a recursive function, the base case stops the recursion.
Question
Consider the accompanying definition of a recursive function.What is the output of the following statement? cout << recFunc(8) << endl;

A) 4
B) 8
C) 72
D) 720
Question
The following is an example of a recursive function, where nextNum is a function such that nextNum(x) = x + 1.
The following is an example of a recursive function, where nextNum is a function such that nextNum(x) = x + 1.  <div style=padding-top: 35px>
Question
Recursive algorithms are implemented using ____________________ functions.
Question
Consider the accompanying definition of a recursive function.What is the output of the following statement? cout << puzzle(3, 7) << endl;

A) 10
B) 21
C) 42
D) 420
Question
Suppose that function A calls function B, function B calls function C, function C calls function D, and function D calls function A.Function A is then ____________________ recursive.
Question
A recursive function in which the last statement executed is the recursive call is called a(n) ____ recursive function.

A) direct
B) tail
C) indefinite
D) indirect
Question
If every recursive call results in another recursive call, then the recursive function (algorithm) is said to have ____ recursion.

A) unlimited
B) indefinite
C) infinite
D) tail
Question
Consider the following recursive definition, where n is a positive integer.
The value of F(3) is ____________________.
Consider the following recursive definition, where n is a positive integer. The value of F(3) is ____________________.  <div style=padding-top: 35px>
Question
Consider the following definition of the recursive function mystery. What is the output of the following statement?
Cout << mystery(6, 10) << endl;
<strong>Consider the following definition of the recursive function mystery. What is the output of the following statement? Cout << mystery(6, 10) << endl;  </strong> A) 13 B) 21 C) 40 D) 42 <div style=padding-top: 35px>

A) 13
B) 21
C) 40
D) 42
Question
Consider the accompanying definition of a recursive function.What is the output of the following statement? cout << puzzle(5, 10) << endl;

A) 720
B) 5040
C) 5760
D) 10800
Question
Which of the following function headings can be used for a recursive definition of a function to calculate the nth Fibonacci number?

A) void rFibNum(int a, int b)
B) bool rFibNum(int a, int b)
C) bool rFibNum(int a, int b, int n)
D) int rFibNum(int a, int b, int n)
Question
Which of the following rules should you follow to solve the Tower of Hanoi problem?

A) Only two disks can be moved at a time.
B) You can remove disks only from the first needle.
C) The removed disk must be placed on a smaller disk.
D) A smaller disk can be placed on top of a larger disk.
Question
Consider the following code.
Consider the following code.   The function fact is an example of a(n) ____________________ recursive function.<div style=padding-top: 35px> The function fact is an example of a(n) ____________________ recursive function.
Question
Consider the accompanying definition of the recursive function mystery.Given the declaration:int alpha[5] = {1, 4, 5, 8, 9}; what is the output of the following statement?
Cout << mystery(alpha, 0, 4) << endl;

A) 1
B) 18
C) 27
D) 35
Question
If a function A calls a function B and function B calls function A, then function A is ____________________ recursive.
Question
A function is called ____ if it calls itself.

A) directly iterative
B) indirectly iterative
C) directly recursive
D) indirectly recursive
Question
Consider the following definition of the recursive function mystery. What is the output of the following statement?
Cout << mystery(5) << endl;
<strong>Consider the following definition of the recursive function mystery. What is the output of the following statement? Cout << mystery(5) << endl;  </strong> A) 50 B) 65 C) 120 D) 180 <div style=padding-top: 35px>

A) 50
B) 65
C) 120
D) 180
Question
____ control structures use a looping structure, such as while, for, or do...while, to repeat a set of statements.

A) Iterative
B) Recursive
C) Procedural
D) Object
Question
Consider the accompanying definition of the recursive function mystery.Given the declaration:int beta[10] = {2, 5, 8, 9, 13, 15, 18, 20, 23, 25}; What is the output of the following statement?
Cout << mystery(beta, 4, 7) << endl;

A) 27
B) 33
C) 55
D) 66
Question
How many needles are used in the Tower of Hanoi problem?

A) one
B) two
C) three
D) four
Question
Which of the following solutions is easier to construct for the Tower of Hanoi problem?

A) Recursive
B) Iterative
C) Procedural
D) Step-by-step
Question
Which of the following solution methods would be the best choice for a mission control system?

A) Iterative
B) Direct recursive
C) Indirect recursive
D) Infinite recursive
Question
In the Tower of Hanoi problem, if needle 1 contains three disks, then the number of moves required to move all three disks from needle 1 to needle 3 is ____________________.
Question
If you execute an infinite recursive function on a computer, the function executes until the system runs out of ____________________.
Question
The ____________________ Fibonacci number in a sequence is the sum of the second and third Fibonacci numbers.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/43
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 15: Recursion
1
Tracing through ____ recursion is more tedious than tracing other recursive forms.

A) direct
B) indirect
C) tail
D) iterative
B
2
Infinite recursions execute forever on a computer.
False
3
Consider the accompanying definition of a recursive function.What is the output of the following statement? cout << recFunc(10) << endl;

A) 10
B) 11
C) 100
D) 110
A
4
You can use a recursive algorithm to find the largest element in an array.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
5
The following is an example of a recursive function.
The following is an example of a recursive function.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
6
Consider the following definition of the recursive function print. What is the output of the following statement?
Print(4);
<strong>Consider the following definition of the recursive function print. What is the output of the following statement? Print(4);  </strong> A) 0 1 2 3 4 B) 1 2 3 4 C) 4 3 2 1 D) 4 3 2 1 0

A) 0 1 2 3 4
B) 1 2 3 4
C) 4 3 2 1
D) 4 3 2 1 0
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
7
Consider the accompanying definition of a recursive function.Which of the statements represents the base case?

A) Statements in Lines 1-6.
B) Statements in Lines 3 and 4.
C) Statements in Lines 5 and 6.
D) Statements in Lines 3, 4, and 5.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
8
A definition in which something is defined in terms of a smaller version of itself is called a(n) ____ definition.

A) step-wise
B) recursive
C) member-wise
D) iterative
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
9
Consider the accompanying definition of a recursive function.Which of the statements represent the general case?

A) Statements in Lines 3-11
B) Statements in Lines 5-6
C) Statements in Lines 5-11
D) Statements in Lines 7-11
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
10
The following is a valid recursive definition to determine the factorial of a non-negative integer.
The following is a valid recursive definition to determine the factorial of a non-negative integer.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
11
In the Tower of Hanoi recursive program, if needle 1 contains three disks, then the number of moves required to move all three disks from needle 1 to needle 3 is 8.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
12
The ____ case is the case for which the solution to an equation is obtained directly.

A) general
B) base
C) direct
D) tail
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
13
To design a recursive function, you must determine the limiting conditions.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
14
Consider the accompanying definition of a recursive function.Which of the statements represent the general case?

A) Statements in Lines 1-6
B) Statements in Lines 3 and 4
C) Statements in Lines 4, 5, and 6
D) Statements in Lines 5 and 6
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
15
Consider the accompanying definition of a recursive function.Which of the statements represent the base case?

A) Statements in Lines 3 and 4
B) Statements in Lines 5 and 6
C) Statements in Lines 3-6
D) Statements in Lines 5-10
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
16
Every call to a recursive function requires the system to allocate memory for the local variables and formal parameters.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
17
With recursion, the base case must eventually be reduced to a general case.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
18
In a recursive function, the base case stops the recursion.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
19
Consider the accompanying definition of a recursive function.What is the output of the following statement? cout << recFunc(8) << endl;

A) 4
B) 8
C) 72
D) 720
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
20
The following is an example of a recursive function, where nextNum is a function such that nextNum(x) = x + 1.
The following is an example of a recursive function, where nextNum is a function such that nextNum(x) = x + 1.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
21
Recursive algorithms are implemented using ____________________ functions.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
22
Consider the accompanying definition of a recursive function.What is the output of the following statement? cout << puzzle(3, 7) << endl;

A) 10
B) 21
C) 42
D) 420
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
23
Suppose that function A calls function B, function B calls function C, function C calls function D, and function D calls function A.Function A is then ____________________ recursive.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
24
A recursive function in which the last statement executed is the recursive call is called a(n) ____ recursive function.

A) direct
B) tail
C) indefinite
D) indirect
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
25
If every recursive call results in another recursive call, then the recursive function (algorithm) is said to have ____ recursion.

A) unlimited
B) indefinite
C) infinite
D) tail
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
26
Consider the following recursive definition, where n is a positive integer.
The value of F(3) is ____________________.
Consider the following recursive definition, where n is a positive integer. The value of F(3) is ____________________.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
27
Consider the following definition of the recursive function mystery. What is the output of the following statement?
Cout << mystery(6, 10) << endl;
<strong>Consider the following definition of the recursive function mystery. What is the output of the following statement? Cout << mystery(6, 10) << endl;  </strong> A) 13 B) 21 C) 40 D) 42

A) 13
B) 21
C) 40
D) 42
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
28
Consider the accompanying definition of a recursive function.What is the output of the following statement? cout << puzzle(5, 10) << endl;

A) 720
B) 5040
C) 5760
D) 10800
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
29
Which of the following function headings can be used for a recursive definition of a function to calculate the nth Fibonacci number?

A) void rFibNum(int a, int b)
B) bool rFibNum(int a, int b)
C) bool rFibNum(int a, int b, int n)
D) int rFibNum(int a, int b, int n)
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
30
Which of the following rules should you follow to solve the Tower of Hanoi problem?

A) Only two disks can be moved at a time.
B) You can remove disks only from the first needle.
C) The removed disk must be placed on a smaller disk.
D) A smaller disk can be placed on top of a larger disk.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
31
Consider the following code.
Consider the following code.   The function fact is an example of a(n) ____________________ recursive function. The function fact is an example of a(n) ____________________ recursive function.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
32
Consider the accompanying definition of the recursive function mystery.Given the declaration:int alpha[5] = {1, 4, 5, 8, 9}; what is the output of the following statement?
Cout << mystery(alpha, 0, 4) << endl;

A) 1
B) 18
C) 27
D) 35
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
33
If a function A calls a function B and function B calls function A, then function A is ____________________ recursive.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
34
A function is called ____ if it calls itself.

A) directly iterative
B) indirectly iterative
C) directly recursive
D) indirectly recursive
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
35
Consider the following definition of the recursive function mystery. What is the output of the following statement?
Cout << mystery(5) << endl;
<strong>Consider the following definition of the recursive function mystery. What is the output of the following statement? Cout << mystery(5) << endl;  </strong> A) 50 B) 65 C) 120 D) 180

A) 50
B) 65
C) 120
D) 180
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
36
____ control structures use a looping structure, such as while, for, or do...while, to repeat a set of statements.

A) Iterative
B) Recursive
C) Procedural
D) Object
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
37
Consider the accompanying definition of the recursive function mystery.Given the declaration:int beta[10] = {2, 5, 8, 9, 13, 15, 18, 20, 23, 25}; What is the output of the following statement?
Cout << mystery(beta, 4, 7) << endl;

A) 27
B) 33
C) 55
D) 66
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
38
How many needles are used in the Tower of Hanoi problem?

A) one
B) two
C) three
D) four
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
39
Which of the following solutions is easier to construct for the Tower of Hanoi problem?

A) Recursive
B) Iterative
C) Procedural
D) Step-by-step
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
40
Which of the following solution methods would be the best choice for a mission control system?

A) Iterative
B) Direct recursive
C) Indirect recursive
D) Infinite recursive
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
41
In the Tower of Hanoi problem, if needle 1 contains three disks, then the number of moves required to move all three disks from needle 1 to needle 3 is ____________________.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
42
If you execute an infinite recursive function on a computer, the function executes until the system runs out of ____________________.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
43
The ____________________ Fibonacci number in a sequence is the sum of the second and third Fibonacci numbers.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 43 flashcards in this deck.