Data Structures & AlgorithmsHardGATE CS · ICPC regional · Product Company SDE
Keys 63, 44, 55, 66, 68, 84, 93, 50, 52, 76 are inserted in this order into an empty BST. What is the height of the tree (edges on the longest root-to-leaf path)?
- A. 5
- B. 2
- C. 9
- D. 4
Correct answer: D. 4
Insert in order; the deepest leaf lies 4 edges below the root 63. (Counting nodes instead of edges gives 5.)
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:13, A–C:16, A–D:20, C–E:2, B–F:18, D–F:10, D–B:23. What is the weight of its minimum…
- In the undirected graph with edges A–B:10, A–C:12, C–D:3, D–E:8, E–F:2, E–A:9, what is the shortest-path distance from A to D?
- A complete binary tree has 87 nodes. How many leaves does it have?
- 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?
- 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?