Data Structures & AlgorithmsHardGATE CS · ICPC regional

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

Correct answer: D. B–C (4)

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic