Data Structures & AlgorithmsModerateGATE CS · ICPC regional

A connected undirected graph has the vertices D, E, O, P, W and weighted edges (weights in brackets): D–P (3), E–P (19), D–E (8), P–O (5), D–W (7), P–W (11), D–O (19), O–W (2). What is the total weight of a minimum spanning tree?

  1. A. 18
  2. B. 57
  3. C. 17
  4. D. 19

Correct answer: A. 18

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic