Data Structures & AlgorithmsVery hardGATE CS
A binary tree with distinct labels has INORDER E G A D B H C F I and LEVEL-ORDER D E I A F G H B C. What is its postorder traversal?
- A. G A E B C H F I D
- B. D E A G I F H B C
- C. C B H F I G A E D
- D. C B H G F A I E D
Correct answer: A. G A E B C H F I D
The first level-order label D is the root; its position in the inorder splits the left and right subtrees, and the earliest level-order label inside each part is that part's root. Rebuilding gives postorder G A E B C H F I D.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- A tree on vertices 1–11 has edges 2–1, 3–2, 4–1, 5–2, 6–3, 7–4, 8–6, 9–8, 10–8, 11–8. What is the size of a maximum independent set (no…
- A 4 × 4 grid has rows 6 6 6 4 / 7 6 5 2 / 2 9 8 2 / 5 1 8 9. Moving only right or down from the top-left to the bottom-right cell, what is…
- Bellman–Ford runs from A on the directed graph whose edges are relaxed in EVERY pass in this fixed order: F→A (9), D→A (4), E→D (8), C→B…
- Floyd–Warshall runs on vertices 1–4 with directed edges 1→2 (1), 1→3 (5), 2→1 (1), 2→4 (8), 3→1 (3), 3→2 (9), 4→3 (2). After the…
- A tree on vertices 1–9 has edges 2–1, 3–1, 4–3, 5–2, 6–4, 7–6, 8–6, 9–8. What are its diameter and radius, and which vertex/vertices form…
- Five matrices have dimensions 12×10 , 10×4 , 4×6 , 6×6 , 6×8. What is the minimum number of scalar multiplications needed to compute their…