Exam 13: Recursion

arrow
  • Select Tags
search iconSearch Question
  • Select Tags

If your method implementation does not animate or animates incorrectly, which of the following should you do?

Free
(Multiple Choice)
4.9/5
(40)
Correct Answer:
Verified

A

Using the gcd method, Aidan coded a program to find the common divisor for 43,822 and 52,003. Instead, he got a StackOverflowError. Infer what happened.

Free
(Essay)
4.9/5
(31)
Correct Answer:
Verified

The base case wasn't identified.

When a method is called, the JVM stores the method's arguments and the caller's return address on a(n):

Free
(Multiple Choice)
4.9/5
(32)
Correct Answer:
Verified

D

Failure to code the base case will result in a runtime error.

(True/False)
4.8/5
(36)

Why might you want to use a recursive method instead of a loop?

(Multiple Choice)
4.8/5
(38)

Typically, recursion uses selection and iteration uses looping.

(True/False)
4.9/5
(37)

A base case must have the words "base case" in order to be coded correctly.

(True/False)
4.7/5
(43)

A recursive method can be a value-returning method.

(True/False)
4.9/5
(31)

You are considering running a program similar to the Tower of Hanoi. Which of the following is true?

(Multiple Choice)
4.7/5
(36)

An iterative function is implemented with looping constructs (e.g., while or for statements) and repeatedly executes the loop.

(True/False)
4.9/5
(35)

Which of the following defines the general case?

(Multiple Choice)
4.8/5
(37)

In the body of a recursive method, there is a call to the method itself.

(True/False)
4.8/5
(36)

What is the factorial of -12?

(Short Answer)
4.8/5
(42)

The factorial of 6 is __________.

(Short Answer)
4.8/5
(35)

A binary search is more easily coded using iteration rather than recursion.

(True/False)
4.8/5
(37)

In a value-returning method, the return statement can include a call to another value-returning method.

(True/False)
4.7/5
(32)

Using recursion, the size of a problem is always reduced by 1 (i.e., from n to n − 1).

(True/False)
4.9/5
(40)

Write a recursive formula in which the following conditions apply: In the first term, both method parameters, n and p, have each been decreased by 1. In the second term, n is unchanged, while p is decreased by 1.

(Essay)
4.8/5
(33)

When searching for a value in an array, what are the possible outcomes?

(Multiple Choice)
4.9/5
(42)

Lynn is having a dinner party for six people. She wrote a factorial program to find out how many possible seating arrangements she has available, but she was stunned when the result was 720. That is too many options. How could she improve her program so that she can find a number of possibilities that she could work with? If she finds that number, how could she incorporate it in her seating decisions?

(Essay)
4.8/5
(31)
Showing 1 - 20 of 59
close modal

Filters

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