Consider the following recursive class method.
Suppose a program called printStuff(4). What would the computer print?public static void printStuff(int n) { if(n > 0) { printStuff(n - 1); IO.println(n); printStuff(n - 2); } }
Consider the following recursive class method.
public static int f(int n) { if(n <= 1) { return 1; } else { return f(n - 1) + f(n / 2); } }
1 2 3 1 4 1 2
5 / \ 4 2 / \ / \ 3 2 1 1 / \ / \ 2 1 1 1 / \ 1 1