Services
Discover
Homeschooling
Ask a Question
Log in
Sign up
Filters
Done
Question type:
Essay
Multiple Choice
Short Answer
True False
Matching
Topic
Computing
Study Set
Big Java Binder Early Objects
Quiz 13: Recursion
Path 4
Access For Free
Share
All types
Filters
Study Flashcards
Practice Exam
Learn
Question 101
Multiple Choice
Consider the following code snippet: public static boolean isEven(int n) { If (n % 2 == 0) { Return true; } Else { Return (isOdd(n) ) ; } } Public static boolean isOdd(int n) { If (n % 2 == 1) { Return true; } Else { Return (isEven(n) ) ; } } For any given value of n, what is the maximum number of function calls that could occur?
Question 102
Multiple Choice
Backtracking _____.
Question 103
Multiple Choice
Complete the following code snippet, which is intended to determine if a value is even or odd using mutual recursion: public static boolean isEven(int n) { If (n == 0) { Return true; } Else { Return isOdd(Math.abs(n) - 1) ; } } Public static boolean isOdd(int n) { If (n == 0) { _________ } Else { Return isEven(Math.abs(n) - 1) ; } }
Question 104
Multiple Choice
Consider the mutually recursive methods below. Select the method call that could be used to generate the output sequence: A5 B4 A3 B2 A1 public static void methodA(int value) { If (value > 0) { System.out.print(" A" + value) ; MethodB(value - 1) ; } } Public static void methodB(int value) { If (value > 0) { System.out.print(" B" + value) ; MethodA(value - 1) ; } }
Question 105
Multiple Choice
Consider the following change to the PermutationGenerator class from the textbook. Instead of adding the removed character to the front of the each permutation of the simpler word, we will add it to the end. // Add the removed character to the end of // each permutation of the simpler word For (String s : shorterWordPermutations) { Result.add(s + word.charAt(i) ) ; } Consider the list produced by the modified PermutationGenerator. Which best describes this list?
Question 106
Multiple Choice
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