Data Structures & AlgorithmsVery hardGATE CS · TCS NQT

A connected undirected weighted graph on vertices 0 to 5 has the edges (u-v with weight): 0-1 (w=1), 0-2 (w=13), 0-3 (w=9), 0-4 (w=11), 1-3 (w=14), 1-5 (w=15), 2-4 (w=9), 3-5 (w=8). What is the total weight of a minimum spanning tree?

  1. A. 52
  2. B. 80
  3. C. 62
  4. D. 38

Correct answer: D. 38

Kruskal's algorithm takes edges in increasing weight and skips any edge that closes a cycle. Adding the n − 1 lightest edges ignores cycles, and taking edges in input order is not minimal.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic