Answer
2
0
1
-1
Work Step by Step
--- Call MysteryPrint(2)
N > 0 → True
Prints 2
Calls MysteryPrint(0)
--- Call MysteryPrint(0)
N > 0 → False, so go to else
Prints 0
Check if (N > -1) → 0 > -1 → True
Calls MysteryPrint(1)
---- Call MysteryPrint(1)
N > 0 → True
Prints 1
Calls MysteryPrint(-1)
--- Call MysteryPrint(-1)
N > 0 → False, so go to else
Prints -1
Check if (N > -1) → -1 > -1 → False
So no further recursive call, recursion ends here.
Now we unwind back up (no more recursion calls left)
No more print statements after recursion, so the full print sequence is:
2, 0, 1, -1