Data Structures & AlgorithmsVery hardGATE CS · ICPC regional

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

Correct answer: A. B–F (5)

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic