Data Structures & AlgorithmsHardGATE CS · Codeforces Div 2 B

A connected undirected graph has the vertices B, F, M, O, Z and weighted edges (weights in brackets): O–M (16), F–Z (14), B–M (7), O–B (8), Z–M (14), O–Z (3), B–Z (5), F–B (9). What is the total weight of a minimum spanning tree?

  1. A. 23
  2. B. 53
  3. C. 24
  4. D. 38

Correct answer: C. 24

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic