The preorder traversal of a binary search tree is 15, 10, 12, 11,20, 18, 16, 19. Which one of the following is the postorder traversal of the tree?

Options

  • A. 20, 19, 18, 16, 15, 12, 11,10
  • B. 11, 12, 10, 16,19,18,20,15
  • C. 19, 16, 18,20,11,12,10,15
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. 11, 12, 10, 16,19,18,20,15

Detailed Explanation

Explanation:

Preorder traversal (Root → Left → Right) is given:
15, 10, 12, 11, 20, 18, 16, 19

Step 1: Root

First element of preorder = 15 → Root

Split into BST parts:

  • Left subtree (<15): 10, 12, 11

  • Right subtree (>15): 20, 18, 16, 19


Left Subtree

Preorder: 10, 12, 11

Root = 10

  • Left of 10 → none

  • Right of 10 → 12, 11

Node 12:

  • Left → 11

Tree:

10
\
12
/
11

Postorder (Left → Right → Root):

11, 12, 10


Right Subtree

Preorder: 20, 18, 16, 19

Root = 20

Left subtree: 18, 16, 19

Node 18

  • Left → 16

  • Right → 19

Tree:

20
/
18
/ \
16 19

Postorder:

16, 19, 18, 20


Final Postorder

Left subtree + Right subtree + Root

11, 12, 10, 16, 19, 18, 20, 15

OOps! You are currently offline.