+ 4
How the recursion is happening ? I want to know that which method is being called in what sequence??
2 Answers
+ 1
run it with this
import java.util.Stack;
...
public void goo(int input[]) {
this.length = input.length;
foo(0, 6, "."); // . dot
}
Stack<String> st = new Stack<>();
int i;
public void foo(int low, int high, String a) {
st.push(low +","+ high +" "+ a +i++); //
System.out.println(st); //
int mid = (low + high) / 2;
if (low < high) {
foo(low, mid, "L"); // L
foo(mid + 1, high, "R"); // R
}
st.pop(); i--; //
}
} //end of class
+ 2
Thanks buddy đ