I don’t understand this method.
protected void inorder(TreeNode<E> root) {
if (root == null) return;
inorder(root.left);
System.out.print(root.element + " ");
inorder(root.right);
}
When current node comes to last node in the tree and current.left become null, what then happened? current node returns where? When that node is going to print?
If
root.leftis null, the function callinorder(root.left);will do nothing but return immediatley and then you will continue on with root and its right subtree.