Data Structures & AlgorithmsHardGATE CS · ICPC regional · Product Company SDE
Keys 23, 80, 66, 86, 46, 82, 50 are inserted one by one into an empty binary search tree. What is the post-order traversal?
- A. [50, 46, 66, 82, 86, 80, 23]
- B. [23, 46, 50, 66, 80, 82, 86]
- C. [23, 80, 66, 46, 50, 86, 82]
- D. [23, 80, 66, 86, 46, 82, 50]
Correct answer: A. [50, 46, 66, 82, 86, 80, 23]
Build the BST by inserting in order (root 23). post-order gives [50, 46, 66, 82, 86, 80, 23]. The other traversals of the same tree are the distractors.
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 43, 47, 54, 30, 28, 26, 20, 64, 45 are inserted in this order into an empty BST. How many nodes lie in the left subtree of the root 43?
- In the undirected graph with edges A–B:7, B–C:9, A–D:3, A–E:2, C–F:3, B–D:4, what is the shortest-path distance from A to B?
- An undirected graph has adjacency lists A:BCG B:ADG C:AE D:BF E:CG F:D G:ABE. Neighbours are always explored in alphabetical order. Which…
- What is the minimum number of nodes in an AVL tree of height 2 (height of a single node = 0)?
- Keys 92, 32, 23, 59, 88, 36, 57, 46, 30 are inserted in this order into an empty BST. How many nodes lie in the left subtree of the root 92?
- An undirected graph has edges (u–v: weight) A–B:7, A–C:12, C–D:14, D–E:15, E–F:2, F–B:23, A–E:17, D–A:29. What is the weight of its…