Find postorder traversal of BST from preorder traversal | Run loop from 1 to length of pre ; Prfrom pivot length - 1 to zero ; Prfrom end to pivot length ; Driver Code
def getPostOrderBST ( pre , N ) : NEW_LINE INDENT pivotPoint = 0 NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT if ( pre [ 0 ] <= pre [ i ] ) : NEW_LINE INDENT pivotPoint = i NEW_LINE break NEW_LINE DEDENT DEDENT for i in range ( pivotPoint - 1 , 0 , - 1 ) : NEW_LINE INDENT print ( pre [ i ] , end = " ▁ " ) NEW_LINE DEDENT for i in range ( N - 1 , pivotPoint - 1 , - 1 ) : NEW_LINE INDENT print ( pre [ i ] , end = " ▁ " ) NEW_LINE DEDENT print ( pre [ 0 ] ) NEW_LINE DEDENT