Data Structures & AlgorithmsVery hardProduct company OA
Weighted undirected graph: A–B 1, B–C 2, C–A 2, C–D 1, B–D 2. How many DIFFERENT minimum spanning trees does it have?
- A. 1
- B. 2
- C. 4
- D. 3
Correct answer: D. 3
Both weight-1 edges (A–B, C–D) are always taken. They leave two components {A, B} and {C, D}, and every weight-2 edge (B–C, C–A, B–D) joins them. Any one of the three completes an MST of weight 4, so there are 3 MSTs. Kruskal returns just one of them, depending on how ties are broken.
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 85, 62, 86, 26, 40, 54, 92, 17, 18, 67 are inserted into an empty AVL tree (giving preorder 62, 40, 18, 17, 26, 54, 86, 85, 67, 92)…
- Keys 20, 24, 27, 35, 38 are searched with frequencies 4, 1, 3, 6, 11 respectively (only successful searches). The cost of a BST is Σ…
- DFS on the directed graph with adjacency lists A: CE; B: EFG; C: B; D: AG; E: C; F: G; G: – starts at A (scanning lists in the order…
- What is the minimum number of edges that must be deleted from the undirected graph with edges A–B, A–D, A–E, B–D, B–F, C–D, C–E, D–E, E–F…
- An undirected connected graph has edges A–C, B–D, B–F, B–H, C–D, C–F, D–G, D–I, E–H, F–G. How many articulation points (cut vertices) and…
- Coins of denominations 1, 9, 10, 11 are available in unlimited supply. What is the minimum number of coins needed to make 18, and how many…