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

An undirected graph has edges (u–v: weight) A–B:30, A–C:9, A–D:11, D–E:14, A–E:25. What is the weight of its minimum spanning tree?

  1. A. 65
  2. B. 62
  3. C. 96
  4. D. 64

Correct answer: D. 64

Kruskal: sort edges and add the cheapest that does not form a cycle: AC(9), AD(11), DE(14), AB(30) → 64. Simply taking the 4 lightest edges may create a cycle.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic