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
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.
Free
(True/False)
4.9/5
(75)
Correct Answer:
False
With recursion,the base case must eventually be reduced to a general case.
Free
(True/False)
4.8/5
(87)
Correct Answer:
False
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 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;
Free
(Multiple Choice)
4.8/5
(96)
Correct Answer:
D
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 ____________________.
(Short Answer)
4.8/5
(78)
You can use a recursive algorithm to find the largest element in an array.
(True/False)
4.9/5
(74)
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(8)<< endl;
(Multiple Choice)
4.8/5
(82)
-Consider the accompanying definition of a recursive function.Which of the statements represent the general case?
(Multiple Choice)
4.9/5
(84)
A(n)____________________ control structure is used to control the repeated calls in recursion.
(Short Answer)
4.7/5
(78)
A definition in which something is defined in terms of a smaller version of itself is called a(n)____ definition.
(Multiple Choice)
4.8/5
(79)
Which of the following solution methods would be the best choice for a mission control system?
(Multiple Choice)
4.9/5
(78)
Consider the following definition of the recursive function mystery. int mystery(int first,int last)
{
if (first > last)
Return 0;
else if (first == last)
Return first;
else
return first + mystery(first + 1,last - 1);
}
What is the output of the following statement?
cout << mystery(6,10)<< endl;
(Multiple Choice)
4.8/5
(74)
Consider the following recursive definition,where n is a positive integer.
F(1)= 3
F(n)= F(n - 1)+ 1 if n > 1
The value of F(3)is ____________________.
(Short Answer)
4.9/5
(68)
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
(True/False)
5.0/5
(80)
To design a recursive function,you must determine the limiting conditions.
(True/False)
4.9/5
(93)
Recursive algorithms are implemented using ____________________ functions.
(Short Answer)
4.9/5
(70)
Let x be an integer.We call the ____________________ of x after division by 2 the rightmost bit of x.
(Short Answer)
4.8/5
(76)
If a function A calls function B and function B calls function A,then function A is ____________________ recursive.
(Short Answer)
4.7/5
(91)
Which of the following function headings can be used for a recursive definition of a function to calculate the nth Fibonacci number?
(Multiple Choice)
4.8/5
(79)
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?
(Multiple Choice)
4.8/5
(68)
Showing 1 - 20 of 50
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)