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

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

  1. A. 32
  2. B. 31
  3. C. 30
  4. D. 34

Correct answer: B. 31

Kruskal: sort edges and add the cheapest that does not form a cycle: BD(3), CE(4), BE(11), AC(13) → 31. Simply taking the 4 lightest edges may create a cycle.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic