Data Structures & AlgorithmsHardGATE CS · ICPC regional
An undirected connected graph on the vertices F, G, Q, S, U has the edges U–G, S–Q, F–Q, U–F, G–S, U–S, S–F, G–Q, U–Q. How many spanning trees does it have? (A spanning tree is a set of edges that connects all vertices with no cycle.)
- A. 5
- B. 32
- C. 76
- D. 75
Correct answer: D. 75
The Matrix-Tree theorem gives the count as any cofactor of the Laplacian, here 75. Choosing any 4 of the 9 edges gives 126 sets, but most of them contain a cycle or leave a vertex out.
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 tree has the vertices A, G, H, I, L, O, P, T, U, Z and the edges G–T, G–U, U–H, H–O, O–Z, Z–P, P–A, A–I, P–L. A set D dominates the tree…
- A grid has 8 rows and 6 columns (rows listed top to bottom; '.' is an open cell, '#' a wall): ...#.. ..##.# ...#.. #..#.. ..###. .#.#…
- A tree on the vertices B, N, P, Q, W, Z has the arcs B→W, N→B, P→N, B→Z, B→Q (each undirected edge is directed as shown). You may reverse…
- An undirected graph has the vertices C, F, M, N, Q, V, X, Z and the edges V–M, V–C, V–N, F–M, F–C, X–Z, X–Q, X–M, Z–M, Z–N, Q–M, M–C. What…
- A grid has 7 rows and 7 columns (top to bottom; '.' open, '#' blocked): .....#. .#..##. ....... .###... ....... #...... ....#.. You may…
- An undirected graph has the vertices G, I, R, U, Y and the edges I–U, Y–G, Y–U, G–U, R–U. What is its chromatic number, the least number…