Data Structures & AlgorithmsHardCodeforces Div 2 D · ICPC regional
An undirected connected graph on 6 vertices has the edges (weights in brackets, all distinct): X–Z (14), X–S (12), V–Z (30), S–Z (4), V–S (6), C–G (19), X–C (2), C–S (7). 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. 50
- B. 38
- C. 68
- D. 43
Correct answer: D. 43
The minimum spanning tree weighs 38. Among the other spanning trees the smallest total is 43, 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 50.
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
- Consider this function: python def g(n): if n < 2: return n if n % 2 == 0: return g(n - 3) + g(n - 2) return g(n - 3) - 1 What value does…
- A connected undirected graph has the vertices F, H, I, M, O, V and the edges F–M, F–I, F–O, M–V, M–H, H–I. How many bridges does it have…
- A counter starts at 1. Each step, you may add 1, add 2, or double the counter. Each step must stay at or below 10. Two sequences of steps…
- An undirected graph has the vertices C, G, I, K, N, W, Y and the edges C–Y, C–I, C–W, C–K, Y–I, Y–W, Y–K, N–I, N–W, G–K, I–K, W–K. What is…
- A directed weighted graph has the arcs u→v (weight): B→U (10), B→S (15), O→U (1), O→S (9), O→P (7), O→L (11), U→O (8), U→S (3), S→L (2)…
- A tree has the vertices D, G, I, J, M, T, X, Y and the edges Y–I, I–J, J–G, J–X, G–T, X–M, Y–D. A set D dominates the tree if every vertex…