The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+13 votes
1.7k views

The pre-order traversal of a binary search tree is given by $12, 8, 6, 2, 7, 9, 10, 16, 15, 19, 17, 20$. Then the post-order traversal of this tree is

  1. $2, 6, 7, 8, 9, 10, 12, 15, 16, 17, 19, 20$
  2. $2, 7, 6, 10, 9, 8, 15, 17, 20, 19, 16, 12$
  3. $7, 2, 6, 8, 9, 10, 20, 17, 19, 15, 16, 12$
  4. $7, 6, 2, 10, 9, 8, 15, 16, 17, 20, 19, 12$
asked in DS by Veteran (346k points)
edited by | 1.7k views
B is the right answer
Clearly root is 12 ,and in post order root is last.So reject A.

Now if you know that left most element will be printed by postorder at first place and left most in inorder is smallest which is 2.

Directly we can give b as answer without construction:)

5 Answers

+11 votes
Best answer

so ans is B

answered by Boss (7.2k points)
edited by
+3 votes
Sorting the given sequence gives Inorder traversal.

Constructing tree gives Option B as the postorder traversal.
answered by Loyal (2.5k points)
0 votes
B) is the answer
answered by Loyal (3.1k points)
–1 vote
answer will be B . 100% sure
answered by Boss (5.1k points)
–1 vote
B is the answer of the above question.
answered by (55 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

33,715 questions
40,263 answers
114,378 comments
38,899 users