The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+6 votes

The following three are known to be the preorder, inorder and postorder sequences of a binary tree. But it is not known which is which.


Pick the true statement from the following.

  1. I and II are preorder and inorder sequences, respectively
  2. I and III are preorder and postorder sequences, respectively
  3. II is the inorder sequence, but nothing more can be said about the other two sequences
  4. II and III are the preorder and inorder sequences, respectively
asked in DS by Veteran (21.5k points)
retagged by | 635 views

4 Answers

+21 votes
Best answer
In preorder, root comes at the beginning of the traversal sequence and in postorder, root comes at the last of the traversal sequence. So, out of the given sequences only 1 and 2 are having such kind of order i.e K at the beginning and at the last.

Therefore, 2 is the preorder and 1 is postorder and the left sequence i.e 3 will definitely be inorder.

So, option d is correct.
answered by Active (2.4k points)
selected by
+6 votes
Answer: D

Binary Tree is:

   /   \                          
  A    Y  
 /   \     \   
M  C    P           
     /     /  \
   B     F  H
answered by Veteran (35.5k points)
+6 votes


Using this as preorder KAMCBYPFH and inorder MABCKYFPH .

So this gives II and III are the preorder and inorder sequences, respectively.

Ans is option D

answered by Veteran (55.4k points)
+2 votes
option D)
answered by Junior (899 points)

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

28,947 questions
36,793 answers
34,690 users