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

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

  1. A. 23
  2. B. 55
  3. C. 46
  4. D. 44

Correct answer: C. 46

Kruskal: sort edges and add the cheapest that does not form a cycle: AE(1), ED(4), BC(7), AC(12), BF(22) → 46. Simply taking the 5 lightest edges may create a cycle.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic