April 18th, 2012, 05:30 AM
Re creating a Binary Tree
Can we re create a Binary Tree Given
1. Any one of the Traversals PreOrder,InOrder, PostOrder? I think no.
2. Any two them? I think Inorder With Pre/Post Order then Yes.
Pre and Post Order(Without Inorder) I think No.
Is this correct ?
April 18th, 2012, 07:44 AM
Re: Re creating a Binary Tree
Answers For re creating a Binary Tree only when the traversals are given
1. Given Only One of the Traversal We cant build a tree
2. Given Inorder + PreOrder/PostOrder Yes we can build a binary tree
3. Given Pre + Post Order we cant build a Tree. Because if there is a single node in a tree we cant Decide where the node should fall Left Or Right. As
In PreOrder Root Left Right and in PostOrder Left Right Root. Now if there is a single node then we cant tell whether it falls on Left Or Right based on traversal data alone. But in case of Inorder it is Left Root Right; Now if there is a single Node then we can identify wether it falls on left or right by looking at Traversal data.
Click Here to Expand Forum to Full Width