VOOZH about

URL: https://www.geeksforgeeks.org/dsa/if-you-are-given-two-traversal-sequences-can-you-construct-the-binary-tree/

⇱ If you are given two traversal sequences, can you construct the binary tree? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

If you are given two traversal sequences, can you construct the binary tree?

Last Updated : 28 May, 2026

It depends on what traversals are given. If one of the traversal methods is Inorder then the tree can be constructed, otherwise not.

👁 Mirror

Therefore, following combination can uniquely identify a tree.

  • Inorder and Preorder. 
  • Inorder and Postorder. 
  • Inorder and Level-order. 

A unique binary tree cannot always be constructed using:

  • Postorder and Preorder. 
  • Preorder and Level-order. 
  • Postorder and Level-order. 

For example, Preorder, Level-order and Postorder traversals are same for the trees given in above diagram. 

  • Preorder Traversal = AB 
  • Postorder Traversal = BA 
  • Level-Order Traversal = AB 

So, even if all three traversals (Preorder, Postorder and Level-order) are given, the tree cannot be uniquely constructed.

Comment
Article Tags: