edited by
6,746 views
21 votes
21 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.

  1. $MBCAFHPYK$
  2. $KAMCBYPFH$
  3. $MABCKYFPH$

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
edited by

3 Answers

Best answer
41 votes
41 votes

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.

edited by
8 votes
8 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

7 votes
7 votes
Answer: D

Binary Tree is:

    K                          
   /   \                          
  A    Y  
 /   \     \   
M  C    P           
     /     /  \
   B     F  H
Answer:

Related questions

42 votes
42 votes
5 answers
2
Ishrat Jahan asked Oct 29, 2014
16,775 views
A binary tree with $n 1$ nodes has $n_1$, $n_2$ and $n_3$ nodes of degree one, two and three respec­tively. The degree of a node is defined as the number of its neighbo...
32 votes
32 votes
2 answers
3
Ishrat Jahan asked Oct 29, 2014
12,453 views
How many distinct BSTs can be constructed with $3$ distinct keys?$4$$5$$6$$9$