Question 7-1

Consider the following recursive class method.

public static void printStuff(int n) {
    if(n > 0) {
        printStuff(n - 1);
        IO.println(n);
        printStuff(n - 2);
    }
}
Suppose a program called printStuff(4). What would the computer print?

Solution

1
2
3
1
4
1
2

Back to Review for Quiz 7