Data Structures & AlgorithmsHardInfosys · Wipro pattern

Kruskal's algorithm runs on edges (weight): A–B 4, A–C 3, B–C 2, B–D 5, C–D 7, C–E 8, D–E 6, D–F 9, E–F 4. What is the total weight of the MST?

  1. A. 20
  2. B. 19
  3. C. 22
  4. D. 24

Correct answer: A. 20

Sorted edges: B–C 2 ✓, A–C 3 ✓, A–B 4 ✗ (cycle), E–F 4 ✓, B–D 5 ✓, D–E 6 ✓ (joins {A,B,C,D} with {E,F}); 5 edges for 6 vertices – done. 2 + 3 + 4 + 5 + 6 = 20. Accepting A–B instead of skipping it inflates the total; picking C–D 7 instead of D–E gives a non-spanning result.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic