Data Structures & AlgorithmsHardGATE CS · ICPC regional · Product Company SDE
Keys 76, 95, 23, 92, 94, 56, 15, 57, 87 are inserted in this order into an empty BST. How many leaf nodes does the tree have?
- A. 2
- B. 6
- C. 4
- D. 12
Correct answer: C. 4
Build the tree; nodes with no children are leaves: 4 of 9.
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 adjacency lists A:BC B:ADE C:ADE D:BC E:BC. Neighbours are always explored in alphabetical order. Which is the DFS…
- How many different spanning trees does the complete graph K7 have (Cayley's formula)?
- Keys 12, 98, 23, 44, 16, 38, 41, 70 are inserted one by one into an empty binary search tree. What is the post-order traversal?
- An undirected graph has edges (u–v: weight) A–B:16, B–C:7, C–D:13, A–E:1, C–F:25, A–C:12, B–F:22, E–D:4. What is the weight of its minimum…
- In the undirected graph with edges A–B:2, A–C:3, A–D:5, C–E:3, E–F:8, F–A:2, what is the shortest-path distance from A to B?
- An undirected graph has adjacency lists A:BCDF B:AC C:AB D:AE E:D F:A. Neighbours are always explored in alphabetical order. Which is the…