Exam 13: Recursion

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

Consider the getArea method from the textbook shown below. Consider the getArea method from the textbook shown below.   What will be the result? What will be the result?

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

D

Consider the following recursive code snippet: Consider the following recursive code snippet:   What parameter values for n would cause an infinite recursion problem in the following method? What parameter values for n would cause an infinite recursion problem in the following method?

Free
(Multiple Choice)
4.8/5
(48)
Correct Answer:
Verified

A

Consider the getArea method from the textbook shown below: Consider the getArea method from the textbook shown below:   If line #1 was eliminated from the method, what would be the result when calling getArea? If line #1 was eliminated from the method, what would be the result when calling getArea?

Free
(Multiple Choice)
4.8/5
(35)
Correct Answer:
Verified

D

Consider the following code snippet for calculating Fibonacci numbers recursively: Consider the following code snippet for calculating Fibonacci numbers recursively:   Identify the terminating condition in this recursive method. Identify the terminating condition in this recursive method.

(Multiple Choice)
4.8/5
(37)

Consider the mutually recursive methods below.Select the method call that could be used to generate the output sequence: A5 B4 A3 B2 A1 Consider the mutually recursive methods below.Select the method call that could be used to generate the output sequence: A5 B4 A3 B2 A1

(Multiple Choice)
4.9/5
(28)

How many recursive calls to the fib method shown below would be made from an original call to fib(4)? (Do not count the original call) How many recursive calls to the fib method shown below would be made from an original call to fib(4)? (Do not count the original call)

(Multiple Choice)
5.0/5
(45)

Consider the permutations method from the textbook, which is intended to return all permutations of the word passed in as a parameter. Consider the permutations method from the textbook, which is intended to return all permutations of the word passed in as a parameter.   If line #8 is changed to add the removed character to the end of each permutation of the shorter word, which change best describes the returned list? result.add(s + word.charAt(i)); // line #8 revised If line #8 is changed to add the removed character to the end of each permutation of the shorter word, which change best describes the returned list? result.add(s + word.charAt(i)); // line #8 revised

(Multiple Choice)
4.8/5
(45)

Consider the method powerOfTwo shown below: Consider the method powerOfTwo shown below:   How many recursive calls are made from the original call powerOfTwo(63) (not including the original call)? How many recursive calls are made from the original call powerOfTwo(63) (not including the original call)?

(Multiple Choice)
4.8/5
(35)

Complete the following code snippet, which is intended to determine if a value is even or odd using mutual recursion: Complete the following code snippet, which is intended to determine if a value is even or odd using mutual recursion:

(Multiple Choice)
4.8/5
(43)

In recursion, the non-recursive case is analogous to a loop ____.

(Multiple Choice)
4.8/5
(32)

A palindrome is a word or phrase that reads the same forward or backward.Consider the following code snippet: A palindrome is a word or phrase that reads the same forward or backward.Consider the following code snippet:   What is the purpose of the palindrome method? What is the purpose of the palindrome method?

(Multiple Choice)
4.8/5
(40)

Which statement is true about backtracking?

(Multiple Choice)
4.7/5
(29)

Which problem-solving technique examines partial solutions, abandons unsuitable ones, and returns to consider other candidate solutions.

(Multiple Choice)
4.9/5
(41)

Consider the iterative version of the fib method from the textbook shown below: Consider the iterative version of the fib method from the textbook shown below:   How many iterations of the for loop will there be for the call fib(6)? How many iterations of the for loop will there be for the call fib(6)?

(Multiple Choice)
4.9/5
(33)

In recursion, the recursive call is analogous to a loop ____.

(Multiple Choice)
4.9/5
(47)

Given the following code snippet: Given the following code snippet:   What value will be returned when this code is executed with a call to newCalc(5)? What value will be returned when this code is executed with a call to newCalc(5)?

(Multiple Choice)
4.7/5
(37)

Consider the getArea method from the textbook shown below: Consider the getArea method from the textbook shown below:   This would cause infinite recursion for ____. This would cause infinite recursion for ____.

(Multiple Choice)
4.9/5
(33)

Consider the method below, which displays the characters from a String in reverse order.Each character appears on a separate line.Select the statement that should be used to complete the method so that it performs a recursive method call correctly. Consider the method below, which displays the characters from a String in reverse order.Each character appears on a separate line.Select the statement that should be used to complete the method so that it performs a recursive method call correctly.

(Multiple Choice)
4.8/5
(44)

Consider the recursive version of the fib method from the textbook shown below: Consider the recursive version of the fib method from the textbook shown below:   How many total recursive calls (not counting the original call) to fib will be made from the original call of fib(7)? How many total recursive calls (not counting the original call) to fib will be made from the original call of fib(7)?

(Multiple Choice)
4.8/5
(31)

Given the following class code: Given the following class code:   What values will be printed when this code is executed? What values will be printed when this code is executed?

(Multiple Choice)
4.7/5
(39)
Showing 1 - 20 of 99
close modal

Filters

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