GATE | GATE CS 2013 | Question 43
The preorder traversal sequence of a binary search tree is 30, 20, 10, 15, 25, 23, 39, 35, 42. Which one of the following is the postorder traversal sequence of the same tree?
(A) 10, 20, 15, 23, 25, 35, 42, 39, 30
(B) 15, 10, 25, 23, 20, 42, 35, 39, 30
(C) 15, 20, 10, 23, 25, 42, 35, 39, 30
(D) 15, 10, 23, 25, 20, 35, 42, 39, 30
Answer: (D)
Explanation: In order to construct a binary tree from given traversal sequences, one of the traversal sequence must be Inorder. The other traversal sequence can be either Preorder or Postorder. We know that the Inorder traversal of Binary Search Tree is always in ascending order so the Inorder Traversal would be the ascending order of given Preorder traversal i.e 10, 15, 20, 23, 25, 30, 35, 39, 42.Now we have to construct a tree from given Inorder and Preorder traversals.
References:
http://www.geeksforgeeks.org/construct-tree-from-given-inorder-and-preorder-traversal/
http://www.geeksforgeeks.org/data-structures-and-algorithms-set-31/
This solution is contributed by Parul sharma.
Recommended Posts:
- GATE | GATE CS 2013 | Question 65
- GATE | GATE CS 2013 | Question 31
- GATE | GATE CS 2013 | Question 30
- GATE | GATE CS 2013 | Question 65
- GATE | GATE CS 2013 | Question 28
- GATE | GATE CS 2013 | Question 65
- GATE | GATE CS 2013 | Question 26
- GATE | GATE CS 2013 | Question 65
- GATE | GATE CS 2013 | Question 25
- GATE | GATE CS 2013 | Question 24
- GATE | GATE CS 2013 | Question 23
- GATE | GATE CS 2013 | Question 22
- GATE | GATE CS 2013 | Question 65
- GATE | GATE CS 2013 | Question 32
- GATE | GATE CS 2013 | Question 33




