Data Structures & AlgorithmsVery hardCodeforces Div 2 C · GATE CS

A connected undirected graph has the vertices B, F, K, N, U, W and weighted edges (weights in brackets): F–U (13), F–N (4), N–U (17), B–W (6), K–B (19), K–N (11), W–U (16), K–F (17), B–F (16), K–U (10). What is the total weight of a minimum spanning tree?

  1. A. 48
  2. B. 44
  3. C. 47
  4. D. 82

Correct answer: C. 47

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic