Data Structures & AlgorithmsVery hardGATE CS · ICPC regional · Product Company SDE

An undirected graph has edges (u–v: weight) A–B:7, A–C:12, C–D:14, D–E:15, E–F:2, F–B:23, A–E:17, D–A:29. What is the weight of its minimum spanning tree?

  1. A. 50
  2. B. 40
  3. C. 52
  4. D. 60

Correct answer: A. 50

Kruskal: sort edges and add the cheapest that does not form a cycle: EF(2), AB(7), AC(12), CD(14), DE(15) → 50. Simply taking the 5 lightest edges may create a cycle.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic