GATE 2017 CS (CS2) – Question 46
BST preorder is 12,8,6,2,7,9,10,16,15,19,17,20. Find its postorder.
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: (B) 2,7,6,10,9,8,15,17,20,19,16,12
Explanation
Root 12 splits left keys below 12 from right keys above 12. The left subtree rooted at 8 has postorder 2,7,6,10,9,8. The right rooted at 16 has 15,17,20,19,16. Appending root 12 gives option B. Every subtree follows left, right, root.