Data Structures & AlgorithmsHardCodeforces Div 2 D · ICPC regional
An undirected connected graph on 6 vertices has the edges (weights in brackets, all distinct): U–A (27), Y–M (6), I–Y (29), U–M (21), A–M (1), R–M (23), R–A (13), A–Y (12), I–A (2). A spanning tree is a set of n − 1 edges with no cycle. What is the weight of the second-smallest spanning tree, meaning the smallest total weight that is strictly larger than the minimum spanning tree weight?
- A. 49
- B. 55
- C. 72
- D. 43
Correct answer: A. 49
The minimum spanning tree weighs 43. Among the other spanning trees the smallest total is 49, obtained by one exchange of an MST edge for a non-tree edge. Adding the cheapest non-tree edge to the MST without the exchange gives 55.
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
- A pile holds p stones. In one move a player removes exactly s stones, where s is one of {2, 5} and s ≤ the pile size. The player who…
- An undirected graph has the vertices B, O, P, Q, T, V, Z and the edges Q–Z, Q–V, Q–T, P–Z, P–B, P–T, Z–O, Z–V, O–B. What is the size of a…
- A tree on the vertices C, F, I, R, V, X has the arcs C→R, V→C, I→V, V→X, F→V (each undirected edge is directed as shown). You may reverse…
- A directed acyclic graph has the vertices A, E, F, H, N, Q, R and the edges Q→N, Q→H, A→N, A→F, N→R, N→F, H→R, H→A, H→E. A topological…
- A directed acyclic graph has the vertices K, L, P, U, W, X, Y and the directed edges Y→W, Y→K, K→L, K→X, P→K, U→X, W→X, W→P, U→P, U→K…
- A tree has the vertices B, D, K, O, Q, V, W, Y, Z and the edges D–K, K–W, W–V, D–B, W–Q, V–Y, V–Z, Q–O. A set D dominates the tree if…