Data Structures & AlgorithmsVery hardGATE CS · ICPC regional

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

Correct answer: D. C–D (4)

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic