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?
- A. A–E (4)
- B. C–F (4)
- C. B–C (6)
- 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.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- Undirected weighted graph on vertices A to G with edges listed as: A–C (5), F–G (2), E–G (4), B–D (6), C–E (1), B–G (4), C–F (1), A–D (4)…
- Undirected weighted graph on vertices A to E with edges listed as: B–E (6), C–D (9), B–D (5), C–E (3), A–E (2), A–C (3), B–C (5)…
- 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)…
- Undirected weighted graph on vertices A to G with edges listed as: B–G (5), D–F (8), E–F (8), B–E (1), D–G (5), A–F (9), D–E (1), E–G (8)…
- Undirected weighted graph on vertices A to G with edges listed as: E–F (5), A–E (1), C–G (8), A–B (9), A–D (6), A–F (1), E–G (5), A–C (3)…
- 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)…