Data Structures & AlgorithmsHardGATE CS · Codeforces Div 2 B
A connected undirected graph has the vertices B, F, M, O, Z and weighted edges (weights in brackets): O–M (16), F–Z (14), B–M (7), O–B (8), Z–M (14), O–Z (3), B–Z (5), F–B (9). What is the total weight of a minimum spanning tree?
- A. 23
- B. 53
- C. 24
- D. 38
Correct answer: C. 24
Kruskal's algorithm (take the cheapest edge that does not form a cycle) gives 24. A heaviest-first spanning tree gives 53, and a shortest-path tree rooted at F gives 38.
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
- An undirected graph has the vertices C, J, L, Q, W and the edges W–L, J–C, L–C, J–Q, Q–L, W–C, W–J, W–Q. How many simple cycles does it…
- A tree on the vertices B, E, G, S, W has the arcs W→E, S→E, B→W, W→G (each undirected edge is directed as shown). You may reverse the…
- The directed acyclic graph has the vertices C, F, G, K, N, T, W and the arcs C→F, W→C, G→N, G→K, N→F, K→F, T→W, W→F, T→F, G→T, K→C, T→K…
- A directed acyclic graph has the vertices B, I, M, Q, R and the arcs B→Q, B→R, I→Q, I→R, I→M, Q→M. Two players alternately move a single…
- Starting from the integer 15, one operation either adds 1, subtracts 1, or doubles the current value. Values may be any non-negative…
- A tree has vertices with weights in brackets: A[5], Z[10], I[13], N[7], L[8], M[15], D[8], R[12], C[9]. The edges are A–Z, Z–I, I–N, A–L…