Find postorder traversal of BST from preorder traversal | Run loop from 1 to length of pre ; Print from pivot length - 1 to zero ; Print from end to pivot length ; Driver Code
using System ; class GFG { public void getPostOrderBST ( int [ ] pre ) { int pivotPoint = 0 ; for ( int i = 1 ; i < pre . Length ; i ++ ) { if ( pre [ 0 ] <= pre [ i ] ) { pivotPoint = i ; break ; } } for ( int i = pivotPoint - 1 ; i > 0 ; i -- ) { Console . Write ( pre [ i ] + " ▁ " ) ; } for ( int i = pre . Length - 1 ; i >= pivotPoint ; i -- ) { Console . Write ( pre [ i ] + " ▁ " ) ; } Console . Write ( pre [ 0 ] ) ; }