Data Structures & AlgorithmsVery hardGATE CS · ICPC regional

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

Correct answer: B. D–E (2)

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic