Data Structures & AlgorithmsHardCodeforces Div 2 D · ICPC regional

A connected undirected graph has the vertices A, B, E, J, M and weighted edges (weights in brackets): M–E (8), A–E (17), M–B (10), A–B (13), J–B (11), A–M (5). What is the total weight of a minimum spanning tree?

  1. A. 51
  2. B. 37
  3. C. 34
  4. D. 35

Correct answer: C. 34

Kruskal's algorithm (take the cheapest edge that does not form a cycle) gives 34. A heaviest-first spanning tree gives 51, and a shortest-path tree rooted at A gives 37.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic