Data Structures & AlgorithmsHardGATE CS · TCS NQT · Product Company SDE

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

  1. A. 31
  2. B. 29
  3. C. 28
  4. D. 27

Correct answer: C. 28

Kruskal: sort edges and add the cheapest that does not form a cycle: CE(2), AE(8), AB(9), BD(9) → 28. Simply taking the 4 lightest edges may create a cycle.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic