Data Structures & AlgorithmsHardGATE CS · ICPC regional
An undirected connected graph on 5 vertices has the edges (weights in brackets, all distinct): B–H (11), B–I (7), C–H (30), E–I (16), B–C (17), B–E (26), E–H (6). 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. 46
- B. 41
- C. 57
- D. 71
Correct answer: A. 46
The minimum spanning tree weighs 41. Among the other spanning trees the smallest total is 46, 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 57.
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 directed graph with no directed cycles has arcs u→v (weight) : U→C (-1), U→Z (6), U→H (8), U→K (8), C→Z (-2), C→H (-1), Z→H (5), Z→K…
- An undirected graph has the vertices C, D, F, L, U, X and the edges F–L, F–D, F–C, L–U, L–C, U–C, X–C. What is the size of a maximum…
- A directed weighted graph has the arcs u→v (weight): Q→H (15), Q→Y (9), H→Q (8), H→Y (3), H→E (13), B→Q (8), B→Y (2), B→E (4), Y→H (2)…
- A connected undirected graph has the vertices B, G, P, R, S and weighted edges (weights in brackets): S–P (19), G–R (10), G–S (14), S–B…
- An undirected connected graph on the vertices B, N, S, V, Z has the edges B–Z, S–Z, S–N, B–V, Z–N, B–N, B–S, Z–V. How many spanning trees…
- An undirected graph has the vertices A, B, E, F, G, I, J, L, N, R and the edges G–J, G–B, G–R, J–F, J–R, F–L, F–B, F–N, F–E, L–N, L–R…