Welcome to Recursion Visualization Comparison

Please read the folowing programming code for a static method for recursion to find factorial of a number in Java. Please see the following visualizations and identify which one is wrong and why.

public class Fac { public static void main(String [ ]args) { System.out.prinln(5+"!=" + factorial(5)); }
public static int factorial(int n) { if(_ _ _ _ ) return 1; else { int result = n * factorial(n - 1); return result; } } }

Visualization1, Visualization2, and Visualization3

Please answer the following Questions:

1. Which of the following visualization is wrong?
Please Choose your answer here:
visualization1
visualization2
visualization3
2. Why is it wrong?
Please choose your answer:
In visualization2, the int variable "result" should never get changed before the entire stack of activation records created
In visualization1, the order of the creation of the stack of return results is wrong
In visualization3, the int variable "result" should get changed before the entire stack of activation records created