Free Access to Data Structures and Abstractions with Java 4th Edition Carrano Test Bank Chapter Answers
Free Access to Data Structures and Abstractions with Java 4th Edition Carrano Test Bank Chapter Answers
https://testbankfan.com/product/data-structures-and-abstractions-with-
java-4th-edition-carrano-solutions-manual/
https://testbankfan.com/product/data-structures-and-abstractions-with-
java-5th-edition-carrano-solutions-manual/
https://testbankfan.com/product/starting-out-with-java-from-control-
structures-through-data-structures-3rd-edition-gaddis-test-bank/
https://testbankfan.com/product/real-estate-finance-and-
investments-14th-edition-brueggeman-test-bank/
Business Law Today Standard Text and Summarized Cases 11th
Edition Miller Solutions Manual
https://testbankfan.com/product/business-law-today-standard-text-and-
summarized-cases-11th-edition-miller-solutions-manual/
https://testbankfan.com/product/essentials-of-cultural-
anthropology-1st-edition-guest-test-bank/
https://testbankfan.com/product/java-foundations-3rd-edition-john-
lewis-test-bank/
https://testbankfan.com/product/anatomy-and-physiology-8th-edition-
patton-test-bank/
https://testbankfan.com/product/international-business-7th-edition-
collinson-solutions-manual/
Introduction to Criminology 3rd Edition Walsh Test Bank
https://testbankfan.com/product/introduction-to-criminology-3rd-
edition-walsh-test-bank/
Chapter 7 - Recursion
True/False (10)
Answer: true
Answer: false
Answer: false
4. You can use a recurrence relation to determine the performance of a recursive method.
Answer: true
Answer: false
6. Activation records for recursive methods are the same as activation records for non-recursive
methods.
Answer: true
Answer: false
8. An iterative solution to the Towers of Hanoi problem moves fewer disks than the recursive
solution.
Answer: false
Answer: true
10. You can replace recursion with iteration by simulating the program stack.
Answer: true
Short Answer (7)
Answer: Each Fibonacci number is calculated multiple times. The larger the Fibonacci sequence, the
more redundant calculations are performed.
2. What is the value returned from the following method when it is called with the value 9?
Answer: 5
4. What is the value returned from the following method when it is called with the value 5?
Answer: 32
5. What does the following method compute?
Answer: It returns true if the value of c is in the array x, otherwise it returns false. The variable b is
the size of the array x.
Answer: It searches an array for the value of c. It returns the array index if the value is found, -1 if it
is not found. The variable b is the size of the array x.
Multiple Choice (25) WARNING: CORRECT ANSWERS ARE IN THE SAME POSITION AND TAGGED
WITH **. YOU SHOULD RANDOMIZE THE LOCATION OF THE CORRECT ANSWERS IN YOUR EXAM.
2. The condition when a recursive method does not satisfy a base case it is called
a. infinite recursion **
b. finite recursion
c. iterative recursion
d. baseless recursion
3. When too many recursive calls are made creating more activation records than the allocated
program memory can handle, what kind of error occurs?
a. stack overflow **
b. activation record overflow
c. recursive overflow
d. infinite recursion
4. What happens when a recursive method does not reach the base case?
a. the program crashes
b. a stack overflow occurs
c. both a & b **
d. none of the above
6. Recursive methods
a. are useful when each recursive all is a solution to a smaller, identical problem **
b. do not use an if-statement
c. are not useful in programming
d. all of the above
8. What question should you keep in mind when debugging a recursive method?
a. Is there at least one recursive call?
b. Did you consider all possible cases?
c. Does the method contain a statement to test an input value and leads to different
cases?
d. All of the above. **
9. What question should you keep in mind when debugging a recursive method?
a. Does each base case produce a result that is correct for that case?
b. are there enough base cases?
c. Is at least one of the cases a base case that has no recursive call?
d. All of the above. **
10. What question should you keep in mind when debugging a recursive method?
a. If the method returns a value, does each of the cases return a value? **
b. Should a for-loop be included in the method?
c. Are the activation records correct?
d. All of the above.
13. To determine the efficiency of a recursive method you need to solve a(n)
a. recurrence relation **
b. recursive relation
c. quadratic equation
d. base case
16. The efficiency for solving the Towers of Hanoi problem recursively is
a. O(2n) **
b. O(n2)
c. O(n)
d. O(log n)
17. The rate of growth for the Towers of Hanoi problem as the number of disks increases is
a. exponential **
b. quadratic
c. linear
d. constant
18. When the last action in a recursive method is a recursive call, it is called
a. tail recursion **
b. final recursion
c. delayed recursion
d. latent recursion
19. When method X calls method Y, method Y calls method Z, and method Z calls method X, this is
called
a. indirect recursion **
b. mutual recursion
c. tail recursion
d. an error
20. When method X calls method Y, and method Y calls method X, this is called
a. mutual recursion **
b. tail recursion
c. associative recursion
d. an error
21. What is the output of the following program when the method is called with 4?
void unknown(int n)
{
System.out.print("?");
if (n > 0)
unknown(n-1);
}
a. ????? **
b. ????
c. ???
d. none of the above
22. What is the output of the following program when the method is called with 4?
void unknown(int n)
{
if (n > 0)
{
System.out.print("?");
unknown(n-1);
}
}
a. ???? **
b. ?????
c. ???
d. none of the above
23. What is the output of the following program when the method is called with 4?
void unknown(int n)
{
if (n > 0)
unknown(n-1);
System.out.print("?");
}
a. ????? **
b. ????
c. ???
d. none of the above
24. How many recursive calls will be made if the following method is called with 6?
void greeting(int n)
{
System.out.println("Hello!");
greeting(n-1);
}
a. infinitely **
b. 7
c. 6
d. 5
25. How many recursive calls will be made if the following method is called with 6?
void greeting(int n)
{
if (n > 0)
{
System.out.println("Hello!");
greeting(n+1);
}
}
a. infinitely **
b. 7
c. 6
d. 5
Discovering Diverse Content Through
Random Scribd Documents
medium, a computer virus, or computer codes that damage or
cannot be read by your equipment.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
testbankfan.com