Bench, truly.. I'm kind of confused with recursion method, probably I need some practice to read recursion more
can you please explain what happened to my
inorder method?
Let's say the inputs are: 5, 2, 9, 1, 3, 11
PHP Code:
public void inorder(BinaryNode node) {
if (node == null) {
return;
}
inorder(node.getLeft());
System.out.println(node.getValue()); // visit the code
inorder(node.getRight());
}
I fixed the problem already lol, just forgot
return; in each of the if statement within the while loop, that causes set the number 3 both on the right side of 1 and 2