in DS edited by
4,894 views
23 votes
23 votes

Which one of the following binary trees has its inorder and preorder traversals as $BCAD$  and $ABCD$, respectively?

in DS edited by
4.9k views

1 comment

In Preorder 1st element is root and everything to left of it in inorder is in LST and right is in RST.

So A is root with BC in LST and D in RST. Option A,C eliminated.

From BC, in preorder B is first so it should be the root. B is elminnated.

So answer is D.

Also as C is after it in inorder it should be in RST(with B as root). So D would be correct.
1
1

4 Answers

28 votes
28 votes
Best answer

Answer is D.

Inorder traversal is left node right.

Preorder is node left right.

edited by

4 Comments

D is correct rt?
1
1
ya D is correct. mistake edited in the answer :)
0
0

Try it ..

0
0

@Puja Mishra

I have seen this figure on 3 questions. In how many questions same figure.

2
2
3 votes
3 votes
Inorder traversal 1) Traverse the left subtree 2) Visit the root 3) Traverse the right subtree Preorder traversal 1) Visit the root 2) Traverse the left subtree 3) Traverse the right subtree
3 votes
3 votes
ans is d

in order left-root-right

preorder root-left right

after applying above formula we get exactly what they asking so d is correct
2 votes
2 votes

By this way we can create tree and Check options so option D is answer

Answer:

Related questions