Create tree(preorder and inorder)

I am having a problem in printing the output. In which way is it getting printed.

in this first you have to print the left side of root node and then root node and then its right node. if right or left node is not present the you have to print β€œEND” . and then same procedure is to be followed for left node of root and then right node of root .
2 => 1 <= END
3 => 2 <= END
END => 3 <= END
Here 1st line means 1 is root node and 2 is its left and no right node of root hence END is written.
Then we visit to left of root node and there 3 is left of 2 and right is not present so END is written.
at the end we visit 3 which is a leaf node hence end is present on both sides.