Recursion Tree Goal: Predict the output of a recursive method call using a recursion tree. Draw the
Fantastic news! We've Found the answer you've been seeking!
Question:
Recursion Tree Goal: Predict the output of a recursive method call using a recursion tree. Draw the recursion tree of the following source code, marking all method calls and outputs:
public static void main(String[ ] args) {
f(5, 2);
}
public static void f(int x, int y) {
if (x > 0 && y > 0) {
f(y - 1, x - 2);
f(x - 2, y);
System.out.print((x + y) + " ");
f(x - 3, y - 1);
System.out.print((x - y) + " ");
}
}
Related Book For
Posted Date: