The preorder traversal of a binary search tree is . Which one of the following is the postorder traversal of the tree?
View worked solution
Answer: B
For any Binary Search Tree (BST), the inorder traversal is always the sorted sequence of its elements in ascending order.
Given the preorder traversal:
Preorder:
Sorting these elements gives the inorder traversal:
Inorder:
Step 1: Reconstructing the BST
- The first element in the preorder traversal is the root: .
- Elements smaller than () form the left subtree.
- Elements larger than () form the right subtree.
By recursively applying this logic, we construct the unique BST:
15
/ \
10 20
\ /
12 18
/ / \
11 16 19
Step 2: Finding the Postorder Traversal
The postorder traversal visits nodes in the order: Left Right Root.
- Postorder of Left Subtree (rooted at ):
- Left of :
- Right of (rooted at ): Left child is , so postorder is .
- Root:
- Result:
- Postorder of Right Subtree (rooted at ):
- Left of (rooted at ): Left child is , right child is , so postorder is .
- Right of :
- Root:
- Result:
- Combine with Root ():
This matches Option B.
Free practice · Your answers on this page are not saved.
