Services
Discover
Homeschooling
Ask a Question
Log in
Sign up
Filters
Done
Question type:
Essay
Multiple Choice
Short Answer
True False
Matching
Topic
Computing
Study Set
C++ Programming Program Design
Quiz 15: Recursion
Path 4
Access For Free
Share
All types
Filters
Study Flashcards
Practice Exam
Learn
Question 1
Multiple Choice
int recFunc(int num) {
\quad
if (num >= 10)
\quad
\quad
return 10;
\quad
else
\quad
\quad
return num * recFunc(num + 1) ; } -Consider the accompanying definition of a recursive function.What is the output of the following statement? cout << recFunc(8) << endl;
Question 2
True/False
In a recursive function,the base case stops the recursion.
Question 3
True/False
With recursion,the base case must eventually be reduced to a general case.
Question 4
True/False
Every call to a recursive function requires the system to allocate memory for the local variables and formal parameters.
Question 5
True/False
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 6
Multiple Choice
int recFunc(int num) {
\quad
if (num >= 10)
\quad
\quad
return 10;
\quad
else
\quad
\quad
return num * recFunc(num + 1) ; } -Consider the accompanying definition of a recursive function.What is the output of the following statement? cout << recFunc(10) << endl;
Question 7
Multiple Choice
-Consider the accompanying definition of a recursive function.Which of the statements represent the base case?
Question 8
True/False
The following is an example of a recursive function,where nextNum is a function such that nextNum(x)= x + 1. int recFunc(int x) { return nextNum(nextNum(x)); }
Question 9
True/False
The following is a valid recursive definition to determine the factorial of a non-negative integer. 0! = 1 1! = 1 n! = n * (n - 1)! if n > 0
Question 10
True/False
The following is an example of a recursive function. void print(int x) {
\quad
if (x > 0)
\quad
{
\quad
\quad
cout << x << " " ;
\quad
\quad
print (x - 1);
\quad
} }
Question 11
True/False
To design a recursive function,you must determine the limiting conditions.
Question 12
Multiple Choice
int recFunc(int num) {
\quad
if (num >= 10)
\quad
\quad
return 10;
\quad
else
\quad
\quad
return num * recFunc(num + 1) ; } -Tracing through ____ recursion is more tedious than tracing other recursive forms.
Question 13
Multiple Choice
int foo(int n) //Line 1 { //Line 2 if (n == 0) //Line 3 return 0; //Line 4 else //Line 5 return n + foo(n - 1) ; //Line 6 } //Line 7 -Consider the accompanying definition of a recursive function.Which of the statements represents the base case?
Question 14
Multiple Choice
A definition in which something is defined in terms of a smaller version of itself is called a(n) ____ definition.
Question 15
Multiple Choice
Consider the following definition of the recursive function print. void print(int num) {
\quad
If (num > 0)
\quad
{
\quad
\quad
Cout << num << " ";
\quad
\quad
Print(num - 1) ;
\quad
} } What is the output of the following statement? Print(4) ;
Question 16
Multiple Choice
-Consider the accompanying definition of a recursive function.Which of the statements represent the general case?
Question 17
Multiple Choice
int foo(int n) //Line 1 { //Line 2 if (n == 0) //Line 3 return 0; //Line 4 else //Line 5 return n + foo(n - 1) ; //Line 6 } //Line 7 -Consider the accompanying definition of a recursive function.Which of the statements represent the general case?