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:

(Multiple Choice)
4.8/5
(43)

Complete the following code snippet, which is intended to be a recursive method that will find the sum of all elements in an array of double values from the beginning of the array to index: Complete the following code snippet, which is intended to be a recursive method that will find the sum of all elements in an array of double values from the beginning of the array to index:

(Multiple Choice)
4.9/5
(38)

Which of the following options could be used as a terminating condition for a recursive method that finds the middle character of a String with any number of characters? i.the length of the String is 1 II.first and last String characters match III.the String is not empty

(Multiple Choice)
4.8/5
(37)

Consider the permutations method from the textbook, which is intended to return all permutations of the word passed in as a parameter.How does the permutations method simplify its input for the recursive call? Consider the permutations method from the textbook, which is intended to return all permutations of the word passed in as a parameter.How does the permutations method simplify its input for the recursive call?

(Multiple Choice)
4.9/5
(41)

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

Consider the fib method from the textbook shown below: Consider the fib method from the textbook shown below:   Computing the 7th fibonacci number, fib(7), recursively computes fib(6), fib(5), and fib(4) ___ times respectively. Computing the 7th fibonacci number, fib(7), recursively computes fib(6), fib(5), and fib(4) ___ times respectively.

(Multiple Choice)
4.8/5
(31)

Consider the method below, which implements the exponentiation operation recursively.Select the statement that should be used to complete the method so that it handles the special case correctly. Consider the method below, which implements the exponentiation operation recursively.Select the statement that should be used to complete the method so that it handles the special case correctly.

(Multiple Choice)
4.8/5
(34)

A palindrome is a word or phrase spelled which reads the same forward or backward.Consider the following code snippet: A palindrome is a word or phrase spelled which reads the same forward or backward.Consider the following code snippet:   What does the method palindrome return? What does the method palindrome return?

(Multiple Choice)
4.8/5
(46)

A palindrome is a word or phrase that reads the same forward or backward.Consider the methods palindrome and isPal shown below: A palindrome is a word or phrase that reads the same forward or backward.Consider the methods palindrome and isPal shown below:   The method isPal as shown here would be considered to be a ____ method. The method isPal as shown here would be considered to be a ____ method.

(Multiple Choice)
4.8/5
(43)

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

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

(Multiple Choice)
4.8/5
(29)

Would switching the special case order affect the return value of the following method? Would switching the special case order affect the return value of the following method?

(Multiple Choice)
4.9/5
(42)

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

Consider the code for the recursive method mystery shown in this code snippet: Consider the code for the recursive method mystery shown in this code snippet:   What will be printed by the statement System.out.println(mystery(-4));? What will be printed by the statement System.out.println(mystery(-4));?

(Multiple Choice)
4.9/5
(32)

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

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

(Multiple Choice)
4.8/5
(30)

In a _____________, a set of cooperating methods calls each other repeatedly.

(Multiple Choice)
4.8/5
(29)

Consider the code for the myFactorial recursive method shown below, which is intended to compute the factorial of the value passed to the method: Consider the code for the myFactorial recursive method shown below, which is intended to compute the factorial of the value passed to the method:   If you set a breakpoint on line #2 and then call myFactorial(4), how many calls to myFactorial will be visible on the debugger's call stack when the program suspends for the breakpoint? If you set a breakpoint on line #2 and then call myFactorial(4), how many calls to myFactorial will be visible on the debugger's call stack when the program suspends for the breakpoint?

(Multiple Choice)
5.0/5
(28)

The method below generates all nonempty substrings of a word passed as argument.Assuming that the string contains no duplicate characters, select the statement to complete the method so that it prints all nonempty substrings correctly. The method below generates all nonempty substrings of a word passed as argument.Assuming that the string contains no duplicate characters, select the statement to complete the method so that it prints all nonempty substrings correctly.

(Multiple Choice)
4.8/5
(39)

If a recursive method does not simplify the computation within the method and the base case is not called, what will be the result?

(Multiple Choice)
4.8/5
(37)
Showing 41 - 60 of 99
close modal

Filters

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