Tree from postorder and inorder

I am getting wrong answer when i am passing an index variable in treebanao() function, but when i am passing it as a reference then i am not getting any error? Why so?