Exam 15: Recursion
Exam 1: Introduction to Computers and Java53 Questions
Exam 2: Java Fundamentals52 Questions
Exam 3: Decision Structures58 Questions
Exam 4: Loops and Files56 Questions
Exam 5: Methods56 Questions
Exam 6: A First Look at Classes58 Questions
Exam 7: Arrays and the Arraylist Class63 Questions
Exam 8: A Second Look at Classes and Objects52 Questions
Exam 9: Text Processing and More About Wrapper Classes62 Questions
Exam 10: Inheritance64 Questions
Exam 11: Exceptions and Advanced File Io59 Questions
Exam 12: Java-Fx: Gui Programming and Basic Controls42 Questions
Exam 13: Java-Fx: Advanced Controls40 Questions
Exam 14: Java-Fx: Graphics, Effects, and Media40 Questions
Exam 15: Recursion23 Questions
Exam 16: Databases40 Questions
Select questions type
Recursion is never absolutely required to solve a problem.
Free
(True/False)
4.9/5
(79)
Correct Answer:
True
In the following code that uses recursion to find the factorial of a number, what is the base case? private static int factorial(int n)
{
If (n == 0)
Return 1;
Else
Return n * factorial(n - 1);
}
Free
(Multiple Choice)
4.9/5
(75)
Correct Answer:
B
When recursive methods directly call themselves, it is known as __________.
Free
(Multiple Choice)
4.8/5
(78)
Correct Answer:
A
Given the following code that uses recursion to find the factorial of a number, how many times will the else clause be executed if n = 5? private static int factorial(int n)
{
If (n == 0)
Return 1;
Else
Return n * factorial(n - 1);
}
(Multiple Choice)
4.9/5
(74)
In the following code that uses recursion to find the greatest common divisor of a number, what is the base case? public static int gcd(int x, int y)
{
If (x % y == 0)
Return y;
Else
Return gcd(y, x % y);
}
(Multiple Choice)
4.9/5
(84)
In the __________, the problem must be reduced to a smaller version of the original problem.
(Multiple Choice)
4.8/5
(84)
To use recursion for a binary search, what is required before the search can proceed?
(Multiple Choice)
4.9/5
(80)
The __________ is at least one case in which a problem can be solved without recursion.
(Multiple Choice)
4.9/5
(81)
A method is called from the main method for the first time. It then calls itself seven times. What is the depth of recursion?
(Multiple Choice)
4.8/5
(83)
Any problem that can be solved recursively can also be solved iteratively, with a loop.
(True/False)
4.9/5
(70)
Without a base case, a recursive method will call itself only once and stop.
(True/False)
4.9/5
(81)
In a recursive program, the number of times a method calls itself is known as the __________.
(Multiple Choice)
4.9/5
(86)
The recursive case does not require recursion so it stops the chain of recursive calls.
(True/False)
4.9/5
(83)
Recursion can be a powerful tool for solving repetitive problems and is an important topic in upper-level computer science courses.
(True/False)
4.9/5
(89)
Whereas a recursive algorithm might result in faster execution time, the programmer might be able to design an iterative algorithm faster.
(True/False)
5.0/5
(79)
The Towers of Hanoi is a mathematical game that is often used in computer science textbooks to illustrate the power of recursion.
(True/False)
4.8/5
(86)
The recursive binary search algorithm is a good example of repeatedly breaking a problem down into smaller pieces until it is solved.
(True/False)
4.9/5
(68)
The actions performed by the JVM that take place with each method call are sometimes referred to as __________.
(Multiple Choice)
4.9/5
(93)
Showing 1 - 20 of 23
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)