Data Structures & AlgorithmsVery hardGATE CS · ICPC regional

Undirected weighted graph on vertices A to E with edges listed as: B–E (6), C–D (9), B–D (5), C–E (3), A–E (2), A–C (3), B–C (5). 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. A–C (3)
  2. B. B–D (5)
  3. C. C–E (3)
  4. D. B–C (5)

Correct answer: B. B–D (5)

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic