Data Structures & AlgorithmsHardGATE CS · ICPC regional

Undirected weighted graph on vertices A to G with edges listed as: B–E (3), E–F (6), B–F (5), F–G (8), D–F (8), A–D (2), D–E (7), D–G (9), A–C (8), A–B (2), B–D (1), E–G (1), C–D (6), A–E (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 fourth edge that Kruskal ADDS?

  1. A. A–B (2)
  2. B. A–D (2)
  3. C. B–E (3)
  4. D. B–F (5)

Correct answer: C. B–E (3)

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic