Exam 13: Recursion

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

Consider the method below, which prints the digits of an arbitrary positive integer in reverse order, one digit per line.The method should print the last digit first.Then, it should recursively print the integer obtained by removing the last digit.Select the statements that should be used to complete the method. Consider the method below, which prints the digits of an arbitrary positive integer in reverse order, one digit per line.The method should print the last digit first.Then, it should recursively print the integer obtained by removing the last digit.Select the statements that should be used to complete the method.

(Multiple Choice)
4.8/5
(49)

Consider the method powerOfTwo shown below: Consider the method powerOfTwo shown below:   What is the best interpretation of line #1? What is the best interpretation of line #1?

(Multiple Choice)
4.9/5
(35)

Consider the getArea method from the book shown below. Consider the getArea method from the book shown below.   What will happen when this code is executed? What will happen when this code is executed?

(Multiple Choice)
4.8/5
(44)

Which of the following executions represent mutual recursion? i.method E calls method T, which calls method F II.method E calls method T, which calls method F, which calls method E III.method F calls method F

(Multiple Choice)
4.9/5
(30)

Assume that recursive method search returns true if argument value is one of the elements in the section of the array limited by the firstIndex and lastIndex arguments.What statement can be used in main to determine if the value 7 is one of the elements in array values? Assume that recursive method search returns true if argument value is one of the elements in the section of the array limited by the firstIndex and lastIndex arguments.What statement can be used in main to determine if the value 7 is one of the elements in array values?

(Multiple Choice)
4.7/5
(31)

A termination condition in a loop is analogous to _____________ in a recursive method.

(Multiple Choice)
4.8/5
(32)

Complete the code for the calcPower recursive method shown below, which is intended to raise the base number passed into the method to the exponent power passed into the method: Complete the code for the calcPower recursive method shown below, which is intended to raise the base number passed into the method to the exponent power passed into the method:

(Multiple Choice)
4.9/5
(37)

If recursion does not have a special terminating case, what error will occur?

(Multiple Choice)
4.7/5
(38)

Recursion does NOT take place if any of the following happen: i.method A calls method B, which calls method C, which calls method B II.method A calls method B, which calls method A III.method A calls method B, B returns, and A calls B again

(Multiple Choice)
4.9/5
(36)

Complete the following code snippet, which is intended to be a recursive method that reverses a String value: Complete the following code snippet, which is intended to be a recursive method that reverses a String value:

(Multiple Choice)
4.8/5
(41)

Consider the square method shown below that takes a non-negative int argument: Consider the square method shown below that takes a non-negative int argument:   What would a call to square(7) return? What would a call to square(7) return?

(Multiple Choice)
4.9/5
(36)

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

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(15)? What value will be returned when this code is executed with a call to newCalc(15)?

(Multiple Choice)
4.9/5
(38)

Consider the recursive method myPrint shown in this code snippet: Consider the recursive method myPrint shown in this code snippet:   What does this method do? What does this method do?

(Multiple Choice)
4.9/5
(38)

Insert the missing code in the following code fragment.This fragment is intended to recursively compute xn, where x and n are both non-negative integers: Insert the missing code in the following code fragment.This fragment is intended to recursively compute x<sup>n</sup>, where x and n are both non-negative integers:

(Multiple Choice)
4.8/5
(46)

Which of the following is NOT true about debugging a recursive method by setting a breakpoint on the line containing a return statement?

(Multiple Choice)
4.8/5
(33)

Complete the code for the myFactorial recursive method shown below, which is intended to compute the factorial of the value passed to the method: Complete the code for the myFactorial recursive method shown below, which is intended to compute the factorial of the value passed to the method:

(Multiple Choice)
4.9/5
(36)

Complete the code for the myFactorial recursive method shown below, which is intended to compute the factorial of the value passed to the method: Complete the code for the myFactorial recursive method shown below, which is intended to compute the factorial of the value passed to the method:

(Multiple Choice)
4.8/5
(39)

Consider the permutations method from the textbook, which is intended to return all permutations of the word passed in as a parameter.Which line contains the recursive call in the permutations method? Consider the permutations method from the textbook, which is intended to return all permutations of the word passed in as a parameter.Which line contains the recursive call in the permutations method?

(Multiple Choice)
4.8/5
(37)

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

(Multiple Choice)
4.9/5
(29)
Showing 61 - 80 of 99
close modal

Filters

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