Data Structures & AlgorithmsHardGATE CS · ICPC regional
A connected undirected graph has the vertices B, H, J, P, Q, V, Z and weighted edges (weights in brackets): J–H (11), Q–P (16), B–P (9), Q–H (15), Z–V (17), B–H (5), J–P (7), Q–V (6). What is the total weight of a minimum spanning tree?
- A. 59
- B. 53
- C. 74
- D. 60
Correct answer: A. 59
Kruskal's algorithm (take the cheapest edge that does not form a cycle) gives 59. A heaviest-first spanning tree gives 74, and a shortest-path tree rooted at Q gives 66.
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 on 5 vertices has the edges C–J, C–D, C–P, J–D, J–P, D–P, P–Z. How many simple paths (no repeated vertex) go from C to…
- Consider this function: python def g(n): if n < 2: return n if n % 2 == 0: return g(n - 3) + g(n - 3) return g(n - 3) - 1 What value does…
- Starting from the integer 14, one operation either adds 1, subtracts 1, or doubles the current value. Values may be any non-negative…
- An undirected graph has the vertices A, H, I, M, R, U, Y, Z and the edges M–Y, M–Z, M–I, M–U, M–H, A–U, A–H, R–Z, R–H, Y–Z, Y–I, Z–I, Z–H…
- A tree has the vertices A, D, F, H, I, K, R, S, X, Z and the edges A–R, R–S, R–X, R–I, X–K, A–H, X–F, S–Z, A–D. What is the minimum number…
- On an 7×7 chessboard, rows and columns are numbered 0 to 6, and squares are written (row, column). A knight moves in the usual L-shape…