Exam 13: Recursion
Exam 1: An Overview of Computers and Programming Languages50 Questions
Exam 2: Basic Elements of Java50 Questions
Exam 3: Introduction to Objects and Input/output50 Questions
Exam 4: Control Structures I: Selection50 Questions
Exam 5: Control Structures II: Repetition50 Questions
Exam 6: Graphical User Interface GUI and Object-Oriented Design OOD50 Questions
Exam 7: User-Defined Methods50 Questions
Exam 8: User-Defined Classes50 Questions
Exam 9: Arrays46 Questions
Exam 10: Inheritance and Polymorphism50 Questions
Exam 11: Handling Exceptions and Events50 Questions
Exam 12: Advanced Guis and Graphics48 Questions
Exam 13: Recursion50 Questions
Exam 14: Applications of Arrays Searching and Sorting and Strings50 Questions
Select questions type
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?
(Multiple Choice)
4.9/5
(28)
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?
(Multiple Choice)
4.8/5
(37)
If every recursive call results in another recursive call, then the recursive method (algorithm) is said to have infinite recursion.
(True/False)
4.8/5
(41)
What is the first step in the Tower of Hanoi recursive algorithm?
(Multiple Choice)
4.8/5
(32)
In the base case of a recursive solution, the solution is obtained through a call to a smaller version of the original method.
(True/False)
4.8/5
(38)
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?
(Multiple Choice)
4.9/5
(39)
A method that calls another method and eventually results in the original method call is called indirectly recursive.
(True/False)
4.8/5
(31)
A program will terminate after completing any particular recursive call.
(True/False)
4.9/5
(41)
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.
(True/False)
4.9/5
(29)
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;
(Multiple Choice)
4.8/5
(35)
You can think of a recursive method as having unlimited copies of itself.
(True/False)
4.8/5
(40)
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)?
(Multiple Choice)
4.9/5
(33)
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?
(Multiple Choice)
4.8/5
(31)
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?
(Multiple Choice)
4.9/5
(38)
A recursive solution is always a better alternative to an iterative solution.
(True/False)
4.9/5
(41)
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));
(Multiple Choice)
4.8/5
(42)
public static int exampleRecursion (int n)
{
If (n == 0)
Return 0;
Else
Return exampleRecursion(n - 1) + n * n * n;
}How many base cases are in the code in the accompanying figure?
(Multiple Choice)
4.8/5
(36)
Showing 21 - 40 of 50
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)