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
Java Software Solutions
Quiz 12: Recursion
Path 4
Access For Free
Share
All types
Filters
Study Flashcards
Practice Exam
Learn
Question 1
Multiple Choice
For the questions below, recall the Towers of Hanoi recursive solution. -If there are 6 disks to move from one Tower to another, how many disk movements would it take to solve the problem using the recursive solution?
Question 2
Multiple Choice
For the questions below, assume that int[ ] a = {6, 2, 4, 6, 2, 1, 6, 2, 5} and consider the two recursive methods below foo and bar. public int foo(int[ ] a, int b, int j) { if (j < a.length) if (a[j] != b) return foo (a, b, j+1) ; else return foo (a, b, j+1) + 1; else return 0; } public int bar(int[ ] a, int j) { if (j < a.length) return a[I] + bar(a, j+1) ; else return 0; } -What is the result of calling foo(a, 2, 0) ;?
Question 3
Multiple Choice
What does the following recursive method determine? Public boolean question16(int[ ]a, int[ ] b, int j) { If (j = = a.length) return false; Else if (j = = b.length) return True; Else return question16(a, b, j+1) ; }
Question 4
Multiple Choice
For the questions below, refer to the following recursive factorial method. public int factorial(int x) { if (x > 1) return x * factorial (x - 1) ; else return 1; } -How many times is the factorial method invoked if originally called with factorial(5) ? Include the original method call in your counting.
Question 5
Multiple Choice
For the questions below, refer to the following recursive factorial method. public int factorial(int x) { if (x > 1) return x * factorial (x - 1) ; else return 1; } -What condition defines the base case for this method?
Question 6
Multiple Choice
For the questions below, use the following recursive method. public int question1_2(int x, int y) { if (x == y) return 0; else return question1_2(x-1, y) + 1; } -If the method is called as question1_2(8, 3) , what is returned?