Data Structures & AlgorithmsHardGATE CS · ICPC regional · Product Company SDE
Keys 87, 32, 67, 97, 11, 60, 23, 69, 21 are inserted in this order into an empty BST. How many nodes lie in the left subtree of the root 87?
- A. 8
- B. 11
- C. 6
- D. 7
Correct answer: D. 7
Exactly the keys smaller than 87 go left, so the left subtree has 7 nodes (the right has 1).
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
- An undirected graph has edges (u–v: weight) A–B:26, B–C:12, B–D:2, D–E:8, A–C:30. What is the weight of its minimum spanning tree?
- A forest has 10 vertices and 2 connected components (trees). How many edges does it have?
- 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?
- 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…