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

An undirected graph has edges (u–v: weight) A–B:3, A–C:21, A–D:19, A–E:17, D–F:13, D–B:29, C–B:27, C–E:2. What is the weight of its minimum spanning tree?

  1. A. 54
  2. B. 65
  3. C. 57
  4. D. 56

Correct answer: A. 54

Kruskal: sort edges and add the cheapest that does not form a cycle: CE(2), AB(3), DF(13), AE(17), AD(19) → 54. Simply taking the 5 lightest edges may create a cycle.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic