Question: calling the function below with func5(4) outputs 2 4 3 2. Im having trouble following a logic tree to see that. can someone explain this

calling the function below with func5(4) outputs 2 4 3 2. Im having trouble following a logic tree to see that. can someone explain this to me simply? I think i understand how it prints the 2 but I have no idea how it prints the 4.

public static void func5(int n) { if (n == 0 || n == 1) return; func5(n - 2); System.out.print(n + " "); func5(n - 1); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!