Data Structures & AlgorithmsModerateGATE CS · ICPC regional

Undirected weighted graph on vertices A to E with edges listed as: C–E (8), A–E (8), A–D (1), B–D (7), B–C (7), A–B (3). Kruskal's algorithm sorts the edges by increasing weight, breaking ties in listed order, and ADDS each edge that does not close a cycle. Which edge is the third edge that Kruskal ADDS?

  1. A. B–D (7)
  2. B. A–B (3)
  3. C. C–E (8)
  4. D. B–C (7)

Correct answer: D. B–C (7)

Kruskal accepts A–D (1), A–B (3), B–C (7), C–E (8) in that order, so the third accepted edge is B–C (7). Taking the 3-th lightest edge without the cycle test (B–D (7)) is the slip.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic