Data Structures & AlgorithmsVery hardGATE CS · TCS NQT · Product Company SDE

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

  1. A. 24
  2. B. 23
  3. C. 26
  4. D. 22

Correct answer: B. 23

Kruskal: sort edges and add the cheapest that does not form a cycle: CE(3), CD(6), AC(6), AB(8) → 23. Simply taking the 4 lightest edges may create a cycle.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic