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.8/5
(39)

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
(34)

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.8/5
(32)

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
(34)

Recursive algorithms are usually less efficient than iterative algorithms.

(True/False)
4.9/5
(44)

The Towers of Hanoi is:

(Multiple Choice)
4.8/5
(29)

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
(41)

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.7/5
(32)

Like a loop, a recursive method must have:

(Multiple Choice)
4.8/5
(32)

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
(40)

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

(Multiple Choice)
5.0/5
(34)

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
(34)

Indirect recursion occurs when:

(Multiple Choice)
4.8/5
(30)

Which of the following problems can be programmed recursively?

(Multiple Choice)
4.8/5
(36)

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

(True/False)
4.8/5
(36)

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

(True/False)
5.0/5
(36)

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

(True/False)
4.9/5
(35)

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
(43)

Recursion can be a powerful tool for solving:

(Multiple Choice)
4.8/5
(35)

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

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

Filters

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