GATE CSE
First time here? Checkout the FAQ!
x
+2 votes
368 views

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
asked in Algorithms by Veteran (19k points)   | 368 views

4 Answers

+12 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.2k points)  
selected by
+4 votes
Answer: D

Binary Tree is:

    K                          
   /   \                          
  A    Y  
 /   \     \   
M  C    P           
     /     /  \
   B     F  H
answered by Veteran (34k points)  
+1 vote
option D)
answered by Junior (851 points)  
+1 vote

 

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 (44.5k points)  
Top Users Feb 2017
  1. Arjun

    5386 Points

  2. Bikram

    4230 Points

  3. Habibkhan

    3952 Points

  4. Aboveallplayer

    3086 Points

  5. Debashish Deka

    2564 Points

  6. sriv_shubham

    2318 Points

  7. Smriti012

    2240 Points

  8. Arnabi

    2008 Points

  9. mcjoshi

    1696 Points

  10. sh!va

    1684 Points

Monthly Topper: Rs. 500 gift card

20,863 questions
26,022 answers
59,696 comments
22,133 users