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

An undirected graph has edges (u–v: weight) A–B:10, A–C:12, A–D:4, D–E:29, D–F:26, D–B:13. What is the weight of its minimum spanning tree?

  1. A. 81
  2. B. 65
  3. C. 78
  4. D. 82

Correct answer: A. 81

Kruskal: sort edges and add the cheapest that does not form a cycle: AD(4), AB(10), AC(12), DF(26), DE(29) → 81. Simply taking the 5 lightest edges may create a cycle.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic