Skip to content

Latest commit

 

History

History

Print Postorder Traversal From Given Inorder And Preorder Traversals

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Given Inorder and Preorder traversals of a binary tree, print Postorder traversal.

Input:
Inorder traversal in[] = {4, 2, 5, 1, 3, 6}
Preorder traversal pre[] = {1, 2, 4, 5, 3, 6}

Output:
Postorder traversal is {4, 5, 2, 6, 3, 1}
Trversals in the above example represents following tree

         1
      /    \    
     2       3
   /   \      \
  4     5      6