Data Structures & AlgorithmsHardGATE CS · ICPC regional

A connected undirected graph has the vertices B, H, J, P, Q, V, Z and weighted edges (weights in brackets): J–H (11), Q–P (16), B–P (9), Q–H (15), Z–V (17), B–H (5), J–P (7), Q–V (6). What is the total weight of a minimum spanning tree?

  1. A. 59
  2. B. 53
  3. C. 74
  4. D. 60

Correct answer: A. 59

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic