Data Structures & AlgorithmsHardGATE CS · ICPC regional

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

Correct answer: B. C–F (5)

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic