Exam 8: Recursion
Exam 1: P A C++ Primer25 Questions
Exam 2: Introduction to Software Design24 Questions
Exam 3: Program Correctness and Efficiency25 Questions
Exam 4: Inheritance and Class Hierarchies25 Questions
Exam 5: Sequential Containers25 Questions
Exam 6: Stacks24 Questions
Exam 7: Queues and Deques25 Questions
Exam 8: Recursion25 Questions
Exam 9: Trees25 Questions
Exam 10: Sets and Maps25 Questions
Exam 11: Sorting25 Questions
Exam 12: Self-Balancing Search Trees25 Questions
Exam 13: Graphs25 Questions
Exam 14: Advanced C++ Topics, and Overview of UML25 Questions
Select questions type
C++ maintains a stack, on which it saves new information in the form of a(n) __________ frame.
Free
(Short Answer)
4.8/5
(36)
Correct Answer:
activation
Which algorithm segment completes the definition for an iterative version of the factorial function?
Int factorial_i (int n) {
Int result = 1;
/** missing code inserted here */
__________
Return result ;
}
Free
(Multiple Choice)
4.9/5
(35)
Correct Answer:
C
Because we eliminate at least __________ of the elements from consideration with each recursive call, binary search is an O(log n) algorithm.
Free
(Multiple Choice)
4.9/5
(37)
Correct Answer:
D
Suppose the function size is called with the argument "ace". When size is later recursively called with the argument "ce", the saved state is represented with the activation frame:
str: "ce"
"ce" == "" is true
return 1 + size("e");
(True/False)
4.7/5
(27)
A recursive problem-solving strategy has divided a problem of size n into two parts. If the larger problem consists of n - 1 items, the smaller problem consists of __________ item (s).
(Multiple Choice)
4.9/5
(35)
The recursive case in the size function below has been incorrectly altered. If the function is called with str = "palindrome", the internal algorithm __________.


(Multiple Choice)
5.0/5
(42)
__________ is an approach to implementing systematic trial and error in a search for a solution.
(Short Answer)
5.0/5
(46)
When performing a binary search against a vector with 262,144 items, __________ probes are required in the worst case scenario.
(Short Answer)
4.9/5
(39)
Which of the following recursive calls enables the fibo function to perform in linear time?


(Multiple Choice)
4.8/5
(31)
A recursive algorithm will stop subdividing a problem after reaching the __________ case.
(Short Answer)
4.8/5
(40)
A proof by __________ works the following way:
• Prove the theorem is true for the base case of (usually) n = 0 or n = 1.
• Show that if the theorem is assumed true for n, then it must be true for n + 1.
(Short Answer)
4.8/5
(39)
The process of returning from the recursive calls and computing the partial results is called __________ the recursion.
(Short Answer)
4.7/5
(34)
The function below is called a(n) __________ function because its only purpose it to call the recursive fibo function and return its result.
int fibonacci_start(int n) {
return fibo(1, 0, n);
}
(Short Answer)
4.9/5
(33)
Rather than examining the last vector element, binary search compares the "__________" element to the target.
(Short Answer)
4.7/5
(40)
On average, a linear search will examine __________ items to find the target if it is in the vector.
(Multiple Choice)
4.8/5
(46)
Suppose you passed 50 to the naive recursive version of the fibonacci function appearing below.
If your CPU could process one million activation frames per second, approximately how much time would the function require to compute the return value?

(Multiple Choice)
4.9/5
(40)
We can always write an iterative solution to a problem that is solvable by recursion.
(True/False)
4.9/5
(34)
To complete the recursive call to gcd, which argument set should be inserted?


(Multiple Choice)
4.9/5
(42)
Showing 1 - 20 of 25
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)