Question #39: diagram link
public static void whatsItDo(String str) {
int len = str.length();
if (len > 1) { // condition that will mark arrival at "base case"
String temp = str.substring(0, len - 1);
whatsItDo(temp);
System.out.println(temp);
}
}
whatsItDo("WATCH");
W
WA
WAT
WATC
Question#40: diagram link
public int recur (int n)
{
if (n <= 10)
{
return n*2;
}
else {
return recur(recur(n / 3));
}
}
recur(27);
16