Exam 13: Recursion

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

Consider the problem of arranging matchsticks so as to form a row of squares, as shown below for three squares and ten matchsticks. Consider the problem of arranging matchsticks so as to form a row of squares, as shown below for three squares and ten matchsticks.

(Multiple Choice)
4.8/5
(39)

When a recursive method is called correctly, and it does not perform recursion, what must be true?

(Multiple Choice)
4.8/5
(43)

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

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

Consider the code for the recursive method riddle shown in this code snippet: Consider the code for the recursive method riddle shown in this code snippet:   To avoid infinite recursion, which of the following lines of code should replace the current terminating case? To avoid infinite recursion, which of the following lines of code should replace the current terminating case?

(Multiple Choice)
4.9/5
(35)

Given the following class code: Given the following class code:   What values will be printed? What values will be printed?

(Multiple Choice)
4.8/5
(40)

Consider the fib method from the textbook shown below. Consider the fib method from the textbook shown below.   Calling fib(3) will trigger ___ recursive call(s) and execute the terminating condition ___ time(s), respectively. Calling fib(3) will trigger ___ recursive call(s) and execute the terminating condition ___ time(s), respectively.

(Multiple Choice)
4.9/5
(31)

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)

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(4) return? What would a call to square(4) return?

(Multiple Choice)
4.8/5
(33)

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

A recursive method without a special terminating case would _________

(Multiple Choice)
4.7/5
(39)

Consider the following recursive code snippet: Consider the following recursive code snippet:   } Identify the terminating condition(s) of method mystery? } Identify the terminating condition(s) of method mystery?

(Multiple Choice)
4.8/5
(40)

Consider the recursive method myPrint: Consider the recursive method myPrint:   What is printed for the call myPrint(8)? What is printed for the call myPrint(8)?

(Multiple Choice)
4.9/5
(43)

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 terminating condition in the permutations recursive 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 terminating condition in the permutations recursive method?

(Multiple Choice)
5.0/5
(38)

Which statement(s) about recursion are true? i.Recursion is faster than iteration. II.Recursion is often easier to understand than iteration. III.Recursive design has an economy of thought.

(Multiple Choice)
5.0/5
(35)

Consider the problem of displaying a pattern of asterisks that form a triangle of height h, as shown below for h = 4: Consider the problem of displaying a pattern of asterisks that form a triangle of height h, as shown below for h = 4:

(Multiple Choice)
4.7/5
(29)

Consider the permutations method from the textbook, which is intended to return all permutations of the word passed in as a parameter.What special cases for the simplest values are used by the permutations method to terminate the recursion? Consider the permutations method from the textbook, which is intended to return all permutations of the word passed in as a parameter.What special cases for the simplest values are used by the permutations method to terminate the recursion?

(Multiple Choice)
4.9/5
(34)

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

Recursion will take place if any of the following happen: i.method A calls method B, which calls method C II.method A calls method B, which calls method A III.method A calls method A

(Multiple Choice)
4.9/5
(47)

Consider the following recursive code snippet: Consider the following recursive code snippet:

(Multiple Choice)
4.9/5
(37)
Showing 21 - 40 of 99
close modal

Filters

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