Exam 13: Recursion

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

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(6)? How many total recursive calls (not counting the original call) to fib will be made from the original call of fib(6)?

(Multiple Choice)
4.7/5
(44)

Complete the following code snippet, which is intended to be a recursive method that will find the smallest value in an array of double values from index to the end of the array: Complete the following code snippet, which is intended to be a recursive method that will find the smallest value in an array of double values from index to the end of the array:

(Multiple Choice)
4.9/5
(38)

____ recursion can occur when a recursive algorithm does not contain a special case to handle the simplest computations directly.

(Multiple Choice)
4.9/5
(41)

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

Consider the following code snippet for recursive addition: Consider the following code snippet for recursive addition:   Identify the terminating condition in this recursive method. Identify the terminating condition in this recursive method.

(Multiple Choice)
4.7/5
(40)

Which of the following statements about recursion is correct?

(Multiple Choice)
4.8/5
(33)

What is required to make a recursive method successful? I.special cases that handle the simplest computations directly II.a recursive call to simplify the computation III.a mutual recursion

(Multiple Choice)
5.0/5
(35)

Consider the getArea method from the textbook shown below. Consider the getArea method from the textbook shown below.   Where is/are the terminating condition(s)? Where is/are the terminating condition(s)?

(Multiple Choice)
4.9/5
(30)

Consider the square method shown below that takes a non-negative int argument.Complete the code for the square method so that it correctly calls the squareHelper method to produce the square of n. Consider the square method shown below that takes a non-negative int argument.Complete the code for the square method so that it correctly calls the squareHelper method to produce the square of n.

(Multiple Choice)
4.7/5
(39)

Consider the following recursive code snippet: Consider the following recursive code snippet:   What value is returned from a call to mystery(3,6)? What value is returned from a call to mystery(3,6)?

(Multiple Choice)
5.0/5
(35)

Complete the code for the recursive method shown below, which is intended to compute the sum of the first n positive integers: Complete the code for the recursive method shown below, which is intended to compute the sum of the first n positive integers:

(Multiple Choice)
4.9/5
(44)

Consider the code for the recursive method printSum shown in this code snippet, which is intended to return the sum of digits from 1 to n: Consider the code for the recursive method printSum shown in this code snippet, which is intended to return the sum of digits from 1 to n:   Which of the following statements is correct? Which of the following statements is correct?

(Multiple Choice)
4.8/5
(36)

Consider the following code snippet: Consider the following code snippet:   For any given value of n, what is the maximum number of function calls that could occur, including the original call? For any given value of n, what is the maximum number of function calls that could occur, including the original call?

(Multiple Choice)
4.9/5
(31)

Why does the best recursive method usually run slightly slower than its iterative counterpart?

(Multiple Choice)
5.0/5
(30)

Consider the getArea method from the textbook shown below. Consider the getArea method from the textbook shown below.   Where is/are the recursive call(s)? Where is/are the recursive call(s)?

(Multiple Choice)
4.9/5
(44)

Consider the recursive method myPrint in this code snippet: Consider the recursive method myPrint in this code snippet:   What is printed for the call myPrint(821)? What is printed for the call myPrint(821)?

(Multiple Choice)
4.7/5
(37)

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 more recursive calls to fib will be made from the original call of fib(7) than from the original call of fib(6) (not counting the original calls)? How many more recursive calls to fib will be made from the original call of fib(7) than from the original call of fib(6) (not counting the original calls)?

(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:

(Multiple Choice)
4.9/5
(34)

Consider the helper method reversePrint, which uses recursion to display in reverse the elements in a section of an array limited by the firstIndex and lastIndex arguments.What statement should be used to complete the recursive method? Consider the helper method reversePrint, which uses recursion to display in reverse the elements in a section of an array limited by the firstIndex and lastIndex arguments.What statement should be used to complete the recursive method?

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

Filters

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