Looks like the recursive printing is messed up. Here printPreOrder
should be calling itself to traverse left and right subtrees than calling printInOrder
to do the traversal.
public static void printPreOrder(Node root) {
if (root!=null){
System.out.print(" " + root.data);
printPreOrder(root.left);
printPreOrder(root.right);
}
}
}