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.
- Given a binary tree, how do you remove all the half nodes?
- K’th Largest Element in BST when modification to BST is not allowed
- Vertex Cover Problem | Set 2 (Dynamic Programming Solution for Tree)
- Check whether a binary tree is a complete tree or not | Set 2 (Recursive Solution)
- Check whether a binary tree is a full binary tree or not
- Find sum of all left leaves in a given Binary Tree
- Remove nodes on root to leaf paths of length < K
- Find the closest leaf in a Binary Tree