GATE | GATE-CS-2004 | Question 35

Consider the label sequences obtained by the following pairs of traversals on a labeled binary tree. Which of these pairs identify a tree uniquely ?

(i)     preorder and postorder
(ii)    inorder and postorder
(iii)   preorder and inorder
(iv)   level order and postorder

(A) (i) only
(B) (ii), (iii)
(C) (iii) only
(D) (iv) only

Answer: (B)

Explanation: Here, we consider each and every option to check whether it is true or false.

1) Preorder and postorder

For the above trees,

Preorder is AB

Postorder is BA

It shows that preorder and postorder can’t identify a tree uniquely.

2) Inorder and postorder define a tree uniquely

3) Preorder and Inorder also define a tree uniquely

4) Levelorder and postorder can’t define a tree uniquely. For the above example,

Level order is AB

Postorder is BA

See for details

This solution is contributed by Anil Saikrishna Devarasetty

Quiz of this Question

My Personal Notes arrow_drop_up
Article Tags :

Be the First to upvote.

Please write to us at to report any issue with the above content.