Preorder to Postorder

question–>https://practice.geeksforgeeks.org/problems/preorder-to-postorder4423/1/?category[]=Binary%20Search%20Tree&category[]=Binary%20Search%20Tree&problemStatus=unsolved&difficulty[]=1&page=1&query=category[]Binary%20Search%20TreeproblemStatusunsolveddifficulty[]1page1category[]Binary%20Search%20Tree#
code–>
https://ide.codingblocks.com/s/423401
showing segmentation fault help

root->right=build(pre,in,index+1,e,i);
this will give error .
follow this:

  1. Create an empty stack.
  2. Make the first value as root. Push it to the stack.
  3. Keep on popping while the stack is not empty and the next value is greater than stack’s top value. Make this value as the right child of the last popped node. Push the new node to the stack.
  4. If the next value is less than the stack’s top value, make this value as the left child of the stack’s top node. Push the new node to the stack.
  5. Repeat steps 2 and 3 until there are items remaining in pre[].