Creating a tree using preorder and inorder

I am getting a slightly different output than the required one. Please help

you have to add one more condition
if(start==end){

    i++;

    return root;

}

Modified Code