The in-order and pre-order traversal of a binary tree are d b e a f c g and a…
2017
The in-order and pre-order traversal of a binary tree are d b e a f c g and a b d e c f g respectively. The post order traversal of a binary tree is
- A.
e d b g f c a
- B.
e d b f g c a
- C.
d e b f g c a
- D.
d e f g b c a
Attempted by 279 students.
Show answer & explanation
Correct answer: C
1. Identify the root node from the pre-order traversal: 'a'.
2. Locate 'a' in the in-order traversal to split left and right subtrees: Left = 'd b e', Right = 'f c g'.
3. Recursively reconstruct the left subtree: Root 'b' (from pre-order 'b d e'). Left child 'd', Right child 'e'. Post-order: d e b.
4. Recursively reconstruct the right subtree: Root 'c' (from pre-order 'c f g'). Left child 'f', Right child 'g'. Post-order: f g c.
5. Combine results for post-order traversal: Left + Right + Root = d e b f g c a.
A video solution is available for this question — log in and enroll to watch it.