GATE Computer ScienceVery hardGATE CS (PYQ pattern)
Prim's algorithm starts at A on a graph with edges AB 6, AC 1, AD 5, BC 5, BE 3, CD 7, CE 8, CF 4, DF 2, EF 9, FG 10, EG 11, DG 12, AG 13. In what order are vertices added to the tree?
- A. A, C, F, D, B, E, G
- B. A, C, F, D, E, B, G
- C. A, C, D, F, B, E, G
- D. A, C, F, B, D, E, G
Correct answer: A. A, C, F, D, B, E, G
From A the cheapest edge is AC 1; then CF 4 (cheaper than AD 5 or BC 5), then FD 2, then BC 5 beats AB 6 so B joins, then BE 3 adds E and finally FG 10 adds G. The MST weight is 1 + 4 + 2 + 5 + 3 + 10 = 25.
More Algorithms questions
- A directed graph on vertices 0–4 has edges (weight): 0→1 2, 1→2 3, 0→2 9, 2→3 1, 1→3 8, 3→4 2, 2→4 7, 0→3 12, 1→4 15. What is the minimum…
- The directed graph on vertices 0–7 has edges 0→1, 1→2, 2→0, 2→3, 4→3, 4→5, 5→4, 6→5, 3→7, 7→3. For how many ordered pairs (u, v) with u ≠…
- A transformation is applied to a connected undirected graph with positive edge weights, and the result is compared with the original…
- Which of the following statements about minimum spanning trees of a connected weighted undirected graph is/are correct? I. If all edge…
- A graph has V = 1000 vertices and E = 250000 edges. Two Dijkstra implementations are compared by counting basic steps (ignoring…
- What is the smallest m such that every simple undirected graph with 12 vertices and m edges is 2-connected (connected, and stays connected…