5,615 views

6 Answers

0 votes
0 votes

If we are given preorder and inorder then we can generate a unique binary tree. But in question we are given only in order. 

So, what we do now -  we take inorder & options one by one (as preorder) and try to make unique binary tree from them.

We will observe that options A & C will fail.

Only B & D can generate unique trees. so, options (B) & (D) are correct

Trees will look like this as given by Pranay Datta 1 

x

0 votes
0 votes

Given:

In-order result=FBGADEC,asking for pre order

Sol:

first construct the tree based on in-order result,ie.rule of in order is left-root-right, now you will get the structure of tree, then apply the pre order rule in that tree ie.,root-left-right you wil get the answer is ABFGCDE.so the answer is option (B)

Related questions

2 votes
2 votes
3 answers
1
2 votes
2 votes
2 answers
3
anurag_am asked Jun 15, 2015
5,996 views
how to convert into inorder traversal if preorder traversal of binary tree is given in the problem ? exaplain using example.
0 votes
0 votes
2 answers
4