Data Structures & AlgorithmsHardGATE CS · ICPC regional

An undirected connected graph on 6 vertices has the edges (weights in brackets, all distinct): U–O (17), F–O (26), O–P (18), U–V (10), F–P (6), V–S (30), U–P (7), F–U (16), F–S (20). 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?

  1. A. 76
  2. B. 61
  3. C. 69
  4. D. 90

Correct answer: B. 61

The minimum spanning tree weighs 60. Among the other spanning trees the smallest total is 61, 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 76.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic