Multiple Choice
Which of the following methods would properly compute the value of x % y (x mod y) recursively, assuming that x and y are not negative numbers?
A) public int recursiveMod(int x, int y)
{
If (x < y) return y;
Else return recursiveMod(x, y - x) ;
}
B) public int recursiveMod(int x, int y)
{
If (x == y) return 0;
Else return recursiveMod(x - y, y) + 1;
}
C) public int recursiveMod(int x, int y)
{
If (x < y) return x;
Else return recursiveMod(x - y, y) + 1;
}
D) public int recursiveMod(int x, int y)
{
If (x < y) return x;
Else return recursiveMod(x - y, y) ;
}
E) public int recursiveMod(int x, int y)
{
While (x > y)
X = x - y;
Return x;
}
Correct Answer:

Verified
Correct Answer:
Verified
Q7: Describe how to solve the Towers of
Q8: Why is the following method one which
Q9: What is a fractal?<br>A) a portion of
Q10: Example Code Ch 12-3<br>Given the two recursive
Q11: The following method should return true if
Q13: The difference between direct and indirect recursion
Q14: Example Code Ch 12-3<br>Given the two recursive
Q15: For the Towers of Hanoi problem, show
Q16: Recall the Towers of Hanoi recursive solution
Q17: The Euclidean algorithm for calculating the greatest