Data Structures & AlgorithmsVery hardGATE CS · Codeforces Div 2 B
An undirected connected graph on 5 vertices has the edges (weights in brackets, all distinct): J–I (26), C–W (25), X–W (27), I–W (24), I–X (4), J–W (23), C–J (29). 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. 76
- B. 78
- C. 102
- D. 105
Correct answer: B. 78
The minimum spanning tree weighs 76. Among the other spanning trees the smallest total is 78, 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 102.
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 tree has vertices with weights in brackets: D[7], N[2], H[11], W[9], L[10], T[5], F[14]. The edges are D–N, N–H, D–W, N–L, W–T, N–F. A…
- A connected undirected graph has the vertices I, K, N, P, U, W and the edges U–W, U–N, U–P, W–K, W–I, N–K, N–I. How many bridges does it…
- An undirected graph on 7 vertices has the edges G–T, G–H, T–E, T–X, E–O, E–H, E–B, O–B. How many simple paths (no repeated vertex) go from…
- A connected undirected graph has the vertices H, K, M, N, R, S, V and the edges V–H, H–S, H–K, H–N, H–M, S–R, N–M. How many bridges does…
- A connected undirected graph has the vertices N, R, U, W, Z and weighted edges (weights in brackets): W–R (7), R–N (1), U–R (16), U–Z (5)…
- An undirected graph has the vertices C, D, P, R, T, W and the edges D–T, T–W, T–P, W–P, P–C, W–C, D–P, R–P, R–C. What is the minimum…