Data Structures & AlgorithmsModerateGATE CS · TCS NQT
Keys 50, 30, 70, 20, 40, 60, 80, 35, 45, 65, 36 are inserted in this order into an empty binary search tree. The post-order traversal of the final tree is:
- A. 20 35 36 45 40 30 65 60 80 70 50
- B. 20 36 35 45 40 30 65 60 80 70 50
- C. 20 36 35 40 45 30 60 65 80 70 50
- D. 20 36 35 45 40 30 60 65 70 80 50
Correct answer: B. 20 36 35 45 40 30 65 60 80 70 50
35 is the left child of 40 and 36 its right child (36 > 35), so post-order visits 36 before 35. The subtree of 70 gives 65, 60 (65 is 60's right child), 80, 70, and the root 50 is last.
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
- Keys 40, 20, 10, 25, 30, 22, 50, 35, 45, 60, 55, 65 are inserted one by one into an initially empty AVL tree. The pre-order traversal of…
- Floyd's bottom-up build-heap (sifting down from the last internal node to the root) is applied to the array [7, 2, 9, 4, 6, 1, 8, 3, 5] to…
- A DAG on vertices 1..6 has edges 1→3, 2→3, 3→4, 3→5, 2→6 and 5→6. How many distinct topological orderings does it have?
- A weighted digraph has edges S→A (2), S→B (5), A→C (4), B→A (−4), B→C (1) and C→T (1). Textbook Dijkstra (a vertex's distance is final…
- An undirected graph on vertices a-f has edges ab(1), bc(2), ac(2), cd(3), bd(3), de(1), ce(4), ae(4), ef(2), df(2). How many distinct…
- A directed graph has the vertices A, B, C, D, E, F, G, H, I and the arcs A→E, B→E, B→F, D→C, E→B, E→C, G→E, G→I, H→B, H→F, I→C, I→H. What…