The inorder and preorder traversal of a binary tree are
and , respectively
The postorder traversal of the binary tree is:
View worked solution
Answer: A
To find the postorder traversal, we first reconstruct the unique binary tree using the given preorder and inorder traversals.
Given:
- Inorder:
- Preorder:
Step 1: Reconstruct the Binary Tree
- The first element in the preorder traversal is the root of the tree. Thus,
ais the root. - Locating
ain the inorder traversal splits the tree into:- Left subtree elements:
- Right subtree elements:
- For the left subtree :
- Its preorder sequence is , so
bis the root of this subtree. - In the inorder sequence ,
dis to the left ofb, andeis to the right. Thus,dis the left child andeis the right child ofb.
- Its preorder sequence is , so
- For the right subtree :
- Its preorder sequence is , so
cis the root of this subtree. - In the inorder sequence ,
fis to the left ofc, andgis to the right. Thus,fis the left child andgis the right child ofc.
- Its preorder sequence is , so
The reconstructed binary tree is:
a
/ \
b c
/ \ / \
d e f g
Step 2: Find the Postorder Traversal
Postorder traversal follows the Left Right Root policy:
- Postorder of left subtree (rooted at
b): - Postorder of right subtree (rooted at
c): - Postorder of the entire tree:
This matches Option A.
Free practice · Your answers on this page are not saved.
