Data Structures & AlgorithmsVery hardGATE CS · TCS NQT
A connected undirected weighted graph on vertices 0 to 7 has the edges (u-v with weight): 0-1 (w=12), 0-3 (w=7), 0-4 (w=7), 1-2 (w=4), 1-3 (w=11), 1-6 (w=14), 2-5 (w=6), 3-7 (w=2), 4-7 (w=12), 5-6 (w=6), 6-7 (w=15). What is the total weight of a minimum spanning tree?
- A. 76
- B. 61
- C. 43
- D. 96
Correct answer: C. 43
Kruskal's algorithm takes edges in increasing weight and skips any edge that closes a cycle. Adding the n − 1 lightest edges ignores cycles, and taking edges in input order is not minimal.
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
- A connected undirected weighted graph on vertices 0 to 7 has the edges (u-v with weight): 0-1 (w=1), 0-4 (w=11), 0-5 (w=15), 0-7 (w=14)…
- A directed acyclic graph on vertices 0 to 7 has these directed edges (u → v): 2→5, 2→6, 2→7, 3→0, 3→7, 4→0, 4→1, 4→3, 5→0, 5→3, 5→7, 6→1…
- A directed acyclic graph on vertices 0 to 7 has these directed edges (u → v): 0→3, 0→4, 0→6, 0→7, 2→1, 2→3, 2→4, 2→7, 3→7, 4→1, 5→0, 5→1…
- A directed acyclic graph on vertices 0 to 7 has these directed edges (u → v): 0→4, 1→3, 1→6, 2→0, 3→0, 6→2, 6→5, 7→0. Among all…
- A directed acyclic graph on vertices 0 to 7 has these directed edges (u → v): 0→6, 1→4, 1→6, 1→7, 2→6, 4→0, 7→2, 7→4, 7→5, 7→6. Among all…
- A directed acyclic graph on vertices 0 to 6 has these directed edges (u → v): 0→3, 0→4, 0→5, 1→3, 2→1, 2→4, 5→1, 5→6. Among all…