Exam 15: Recursion
Exam 1: An Overview of Computers and Programming Languages50 Questions
Exam 2: Basic Elements of C++50 Questions
Exam 3: Input/Output50 Questions
Exam 4: Control Structures I (Selection)50 Questions
Exam 5: Control Structures II (Repetition)50 Questions
Exam 6: User-Defined Functions50 Questions
Exam 7: User-Defined Simple Data Types, Namespaces, and the string Type50 Questions
Exam 8: Arrays and Strings50 Questions
Exam 9: Records (structs)50 Questions
Exam 10: Classes and Data Abstraction50 Questions
Exam 11: Inheritance and Composition50 Questions
Exam 12: Pointers, Classes, Virtual Functions, Abstract Classes, and Lists50 Questions
Exam 13: Overloading and Templates50 Questions
Exam 14: Exception Handling50 Questions
Exam 15: Recursion50 Questions
Exam 16: Linked Lists50 Questions
Exam 17: Stacks and Queues50 Questions
Exam 18: Searching and Sorting Algorithms50 Questions
Exam 19: Binary Trees50 Questions
Exam 20: Graphs50 Questions
Exam 21: Standard Template Library (STL)50 Questions
Select questions type
-Consider the accompanying definition of a recursive function.Which of the statements represent the base case?
(Multiple Choice)
4.8/5
(71)
Consider the following definition of the recursive function mystery.
int mystery(int num)
{
if (num <= 0)
return 0;
else if (num % 2 == 0)
return num + mystery(num - 1);
else
return num * mystery(num - 1);
}
What is the output of the following statement?
Cout << mystery(5)<< endl;
(Multiple Choice)
4.9/5
(66)
The language of a computer,called ____________________ language,is a series of 0s and 1s.
(Short Answer)
4.9/5
(87)
Consider the following definition of the recursive function print. void print(int num)
{
If (num > 0)
{
Cout << num << " ";
Print(num - 1);
}
}
What is the output of the following statement?
Print(4);
(Multiple Choice)
5.0/5
(85)
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?
(Multiple Choice)
4.8/5
(86)
The fourth Fibonacci number in a sequence is the sum of the ____________________ Fibonacci numbers.
(Short Answer)
4.8/5
(80)
The ____ case is the case for which the solution is obtained directly.
(Multiple Choice)
4.8/5
(81)
The numbering system that the computer uses is called the ____________________ system.
(Short Answer)
4.9/5
(78)
int puzzle(int start, int end)
{
if (start > end)
return start - end;
else if (start == end)
return start + end;
else
return end * puzzle(start + 1, end - 1);
}
-Consider the accompanying definition of a recursive function.What is the output of the following statement? cout << puzzle(5,10)<< endl;
(Multiple Choice)
4.7/5
(81)
____ control structures use a looping structure,such as while,for,or do...while,to repeat a set of statements.
(Multiple Choice)
4.7/5
(79)
int recFunc(int num)
{
if (num >= 10)
return 10;
else
return num * recFunc(num + 1);
}
-Tracing through ____ recursion is more tedious than tracing other recursive forms.
(Multiple Choice)
4.9/5
(80)
int mystery(int list[ ], int first, int last)
{
if (first == last)
return list[first];
else
return list[first] + mystery(list, first + 1, last);
}
-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;
(Multiple Choice)
4.8/5
(69)
Which of the following solutions is easier to construct for the Tower of Hanoi problem?
(Multiple Choice)
4.9/5
(70)
Every call to a recursive function requires the system to allocate memory for the local variables and formal parameters.
(True/False)
4.9/5
(80)
Consider the following code.
int fact(int num)
{
if (num == 0)
return 1;
else
return num * fact(num - 1);
}
The function fact is an example of a(n)____________________ recursive function.
(Short Answer)
4.8/5
(71)
The collating sequence of A in the ASCII character set is ____________________.
(Short Answer)
4.9/5
(74)
If you execute a(n)____________________ recursive function on a computer,the function executes until the system runs out of memory.
(Short Answer)
4.8/5
(76)
The following is an example of a recursive function.
void print(int x)
{
if (x > 0)
{
cout << x << " " ;
print (x - 1);
}
}
(True/False)
4.7/5
(69)
int recFunc(int num)
{
if (num >= 10)
return 10;
else
return num * recFunc(num + 1);
}
-A function is called ____ if it calls itself.
(Multiple Choice)
4.9/5
(82)
int recFunc(int num)
{
if (num >= 10)
return 10;
else
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;
(Multiple Choice)
4.8/5
(82)
Showing 21 - 40 of 50
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)