If you are given two traversal sequences, can you construct the binary tree?
It depends on what traversals are given. If one of the traversal methods is Inorder then the tree can be constructed, otherwise not.
Therefore, following combination can uniquely identify a tree.
Inorder and Preorder.
Inorder and Postorder.
Inorder and Level-order.
And following do not.
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 three of them (Pre, Post and Level) are given, the tree can not be constructed.
Recommended Posts:
- Construct Full Binary Tree using its Preorder traversal and Preorder traversal of its mirror tree
- Construct Special Binary Tree from given Inorder traversal
- Construct a special tree from given preorder traversal
- Construct the full k-ary tree from its preorder traversal
- Construct the Rooted tree by using start and finish time of its DFS traversal
- Given level order traversal of a Binary Tree, check if the Tree is a Min-Heap
- Construct a Binary Search Tree from given postorder
- Construct a Binary Tree from Postorder and Inorder
- Construct Ancestor Matrix from a Given Binary Tree
- Construct Binary Tree from given Parent Array representation
- Construct Binary Tree from String with bracket representation
- Construct Complete Binary Tree from its Linked List Representation
- Construct Full Binary Tree from given preorder and postorder traversals
- Construct a complete binary tree from given array in level order fashion
- Construct Binary Tree from given Parent Array representation | Iterative Approach



