# A binary search tree contains values 7, 8, 13, 26, 35, 40, 70, 75. Which one of the following is a valid post-order sequence of the tree provided the pre-order sequence as 35, 13, 7, 8, 26, 70, 40 and 75?

+1 vote
A binary search tree contains values 7, 8, 13, 26, 35, 40, 70, 75. Which one of the following is a valid post-order sequence of the tree provided the pre-order sequence as 35, 13, 7, 8, 26, 70, 40 and 75?

(a) 7, 8, 26, 13, 75, 40, 70, 35

(b) 26, 13, 7, 8, 70, 75, 40, 35

(c) 7, 8, 13, 26, 35, 40, 70, 75

(d) 8, 7, 26, 13, 40, 75, 70, 35

I'm obligated to ask this question of Binary Trees in portion Binary Trees of Data Structures & Algorithms I

I have been asked this question in an online interview.

+1 vote
by (789k points)
selected by

Correct choice is (d) 8, 7, 26, 13, 40, 75, 70, 35

For explanation: The binary tree contains values 7, 8, 13, 26, 35, 40, 70, 75. The given pre-order sequence is 35, 13, 7, 8, 26, 70, 40 and 75. So, the binary search tree formed is

Thus post-order sequence for the tree is 8, 7, 26, 13, 40, 75, 70 and 35.

+1 vote
+1 vote
+1 vote
+1 vote
+1 vote
+1 vote
+1 vote
+1 vote
+1 vote
+1 vote
+1 vote
+1 vote
+1 vote
+1 vote
+1 vote
+1 vote
+1 vote
+1 vote
+1 vote