Services
Discover
Ask a Question
Log in
Sign up
Filters
Done
Question type:
Essay
Multiple Choice
Short Answer
True False
Matching
Topic
Computing
Study Set
Java Programming From Problem Analysis to Program Design
Exam 13: Recursion
Path 4
Access For Free
Share
All types
Filters
Study Flashcards
Practice Exam
Learn
Question 21
Multiple Choice
public static int exampleRecursion (int n) { If (n == 0) Return 0; Else Return exampleRecursion(n - 1) + n * n * n; }Which of the following is an invalid call to the method in the accompanying figure?
Question 22
Multiple Choice
public static int func2(int m, int n) { If (n == 0) Return 0; Else Return m + func2(m, n - 1) ; }What is the limiting condition of the code in the accompanying figure?
Question 23
True/False
If every recursive call results in another recursive call, then the recursive method (algorithm) is said to have infinite recursion.
Question 24
Multiple Choice
The third Fibonacci number is ____.
Question 25
Multiple Choice
What is the first step in the Tower of Hanoi recursive algorithm?
Question 26
True/False
In the base case of a recursive solution, the solution is obtained through a call to a smaller version of the original method.
Question 27
Multiple Choice
public static int func2(int m, int n) { If (n == 0) Return 0; Else Return m + func2(m, n - 1) ; }Which of the following statements about the code in the accompanying is always true?
Question 28
True/False
A method that calls another method and eventually results in the original method call is called indirectly recursive.
Question 29
True/False
A program will terminate after completing any particular recursive call.
Question 30
True/False
The following is an example of a recursive method.public static int recFunc(int x) { return (nextNum(nextNum(x))); }where nextNum is method such that nextNum(x) = x + 1.
Question 31
True/False
Every recursive call has its own code.
Question 32
Multiple Choice
Which of the following statements describe the base case of a recursive algorithm? (i) F(0) = 0; (ii) F(x) = 2 * F(x - 1) ; (iii) if (x == 0) F(x) = 5 + x;
Question 33
True/False
The base case starts the recursion.
Question 34
True/False
You can think of a recursive method as having unlimited copies of itself.
Question 35
Multiple Choice
public static int exampleRecursion (int n) { If (n == 0) Return 0; Else Return exampleRecursion(n - 1) + n * n * n; }What is the output of exampleRecursion(0) ?
Question 36
Multiple Choice
public static int exampleRecursion (int n) { If (n == 0) Return 0; Else Return exampleRecursion(n - 1) + n * n * n; }What does the code in the accompanying figure do?
Question 37
Multiple Choice
Assume there are four methods A, B, C, and D. If method A calls method B, method B calls method C, method C calls method D, and method D calls method A, which of the following methods is indirectly recursive?
Question 38
True/False
A recursive solution is always a better alternative to an iterative solution.
Question 39
Multiple Choice
Consider the following definition of a recursive method.public static int recFunc(int num) { If (num >= 10) Return 10; Else Return num * recFunc(num + 1) ; }What is the output of the following statement?System.out.println(recFunc(8) ) ;