Question: Question 110 pts What is the value returned from the following method when it is called with the value 9? int mystery (int n) {
Question 110 pts
What is the value returned from the following method when it is called with the value 9? int mystery (int n) { if (n < 1) return 0; else if (n % 2 == 0) return mystery(n-1); else return 1 + mystery(n-1); }
Group of answer choices
4
5
6
7
Flag question: Question 2
Question 210 pts
public static int f(int [] a, int begin, int end) { if(begin == end) { return a[begin]; } int mid = (begin + end)/2; int a1 =f(a, begin, mid); int a2 = f(a, mid + 1, end);
return (a1 > a2) ? a1 : a2; }
Group of answer choices
the sum of elements in a
the multiplication of elements in a
the maximum element in a
the minimum element in a
Flag question: Question 3
Question 310 pts
When too many recursive calls are made creating more activation records than the allocated program memory can handle, what kind of error occurs?
Group of answer choices
activation record overflow
recursive overflow
infinite recursion
stack overflow
Flag question: Question 4
Question 410 pts
A recursive method that processes a chain of linked nodes.
Group of answer choices
uses the first node in the chain
uses the last node in the chain
divides the chain in half placing the middle node in the left chain
divides the chain in half placing the middle node in the right chain
Flag question: Question 5
Question 510 pts
The number of recursive calls required for recursively calculating xn is
Group of answer choices
1 + n^2
1 + n log n
1 + n
1+ log n
Flag question: Question 6
Question 610 pts
The rate of growth for the Towers of Hanoi problem as the number of disks increases is
Group of answer choices
exponential
quadratic
linear
constant
Flag question: Question 7
Question 710 pts
When the last action in a recursive method is a recursive call, it is called
Group of answer choices
final recursion
delayed recursion
tail recursion
latent recursion
Flag question: Question 8
Question 810 pts
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); } }
Group of answer choices
?????
????
???
None of the above
Flag question: Question 9
Question 910 pts
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); }
Group of answer choices
5
6
7
infinite
Flag question: Question 10
Question 1010 pts
A recursive method uses less memory than an iterative method.
Group of answer choices
True
False
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
