Exam 16: Recursion

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

This type of method is a method that calls itself.

(Multiple Choice)
4.9/5
(72)

Look at the following method: public static int Test2(int x, int y) { If ( x < y) { Return -5; } Else { Return (Test2(x - y, y + 5) + 6); } } What is the base case for the method?

(Multiple Choice)
4.8/5
(69)

Look at the following pseudocode algorithm: algorithm Test14(int x) If (x < 8) Return (2 * x) Else Return (3 * Test14(x - 8) + 8) End Test14 What value is returned for Test14(7)?

(Multiple Choice)
4.9/5
(77)

Look at the following method: public static int test2(int x, int y) { If ( x < y) { Return -5; } Else { Return (test2(x - y, y + 5) + 6); } } What is returned for test2(10, 20)?

(Multiple Choice)
4.9/5
(77)

Recursive algorithms are usually less efficient than iterative algorithms.

(True/False)
4.9/5
(91)

The Towers of Hanoi is:

(Multiple Choice)
4.9/5
(85)

How many times will the following method call itself if the value 10 is passed as an argument? Public static void message(int n) { If (n > 0) { System.out.println("Print this line.\n"); Message(n + 1); } }

(Multiple Choice)
4.8/5
(87)

To solve a program recursively, you need to identify at least one case in which the problem can be solved without recursion - this is known as the:

(Multiple Choice)
4.8/5
(66)

Like a loop, a recursive method must have:

(Multiple Choice)
4.8/5
(71)

Look at the following pseudocode algorithm: algorithm Test14(int x) If (x < 8) Return (2 * x) Else Return (3 * Test14(x - 8) + 8) End Test14 What value is returned for Test14(16)?

(Multiple Choice)
4.8/5
(71)

The actions that the JVM must perform any time a method is called are known as:

(Multiple Choice)
5.0/5
(78)

Look at the following method: public static int test2(int x, int y) { If ( x < y) { Return -5; } Else { Return (test2(x - y, y + 5) + 6); } } What is the recursive case for the method?

(Multiple Choice)
4.8/5
(67)

Indirect recursion occurs when:

(Multiple Choice)
4.9/5
(74)

Which of the following problems can be programmed recursively?

(Multiple Choice)
4.9/5
(83)

If method A calls method B, which in turn calls method A, it is called indirect recursion.

(True/False)
4.8/5
(71)

Indirect recursion occurs when a method calls another method that in turn calls the first method.

(True/False)
5.0/5
(72)

In Java, it is not possible for a method to call itself.

(True/False)
4.9/5
(77)

A problem can be solved recursively if it can be broken down into successive smaller problems that are identical to the overall problem.

(True/False)
4.9/5
(90)

Recursion can be a powerful tool for solving:

(Multiple Choice)
4.8/5
(78)

Usually, a problem is reduced by making the value of one or more parameters ________ with each recursive call.

(Multiple Choice)
4.7/5
(81)
Showing 21 - 40 of 42
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)