Help needed in debugging the code. Binary Tree From Inorder and Preorder

My code is showing wrong output. Could you help me out in finding the error? Moreover i am not able to find the way to print the binary tree as stated in question. So, could you help me out in coding out the modified preorder as stated in question?