Data Structures & AlgorithmsHardGATE CS · Codeforces Div 2 B
An undirected connected graph on the vertices B, H, O, P, S has the edges H–S, O–B, S–P, H–P, S–B, B–P, H–B. How many spanning trees does it have? (A spanning tree is a set of edges that connects all vertices with no cycle.)
- A. 17
- B. 16
- C. 8
- D. 35
Correct answer: B. 16
The Matrix-Tree theorem gives the count as any cofactor of the Laplacian, here 16. Choosing any 4 of the 7 edges gives 35 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 vertices A, C, G, J, N, Q, X, Y and weighted edges (weights in brackets): Y–Q (2), Y–X (5), Y–J (2), J–C (2), C–A (8), X–G (7)…
- Two unmarked jugs hold 5 litres and 7 litres. Allowed operations: fill a jug completely, empty a jug completely, or pour one jug into the…
- 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)…
- 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…