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

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

  1. A. 48
  2. B. 58
  3. C. 38
  4. D. 53

Correct answer: A. 48

Kruskal: sort edges and add the cheapest that does not form a cycle: BD(2), DE(8), BC(12), AB(26) → 48. Simply taking the 4 lightest edges may create a cycle.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic