Data Structures & AlgorithmsHardGATE CS · ICPC regional
An undirected connected graph on the vertices E, I, L, Y, Z has the edges Y–I, Y–Z, E–Y, L–Z, E–Z, E–I. How many spanning trees does it have? (A spanning tree is a set of edges that connects all vertices with no cycle.)
- A. 2
- B. 8
- C. 4
- D. 9
Correct answer: B. 8
The Matrix-Tree theorem gives the count as any cofactor of the Laplacian, here 8. Choosing any 4 of the 6 edges gives 15 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 bipartite graph has left side P1, P2, P3, P4 and right side Q1, Q2, Q3, Q4, with edges P2–Q3, P2–Q1, P2–Q2, P3–Q4, P1–Q3, P3–Q3. What is…
- Bellman–Ford is run from source T on the directed graph whose arcs (weights in brackets) are listed in the order they are relaxed: P→Y…
- A directed graph has the vertices A, G, N, S, T, Y, Z and the arcs N→A, N→S, T→N, T→Z, T→Y, T→S, A→N, A→Y, Z→N, Z→T, Z→Y, Z→S, G→N, G→A…
- A tree has the vertices C, I, N, P, T, U, X, Y, Z and the edges N–Z, N–Y, N–U, Y–I, I–X, N–C, Y–T, T–P. What is the minimum number of…
- A tree has the vertices A, B, C, H, L, V, W and the edges C–W, W–H, H–B, B–A, C–L, A–V. A centroid is a vertex whose removal leaves no…
- Cities M, R, T, V, W are joined by roads with these travel costs: W–M 7, W–R 14, W–V 12, W–T 8, M–R 19, M–V 20, M–T 5, R–V 15, R–T 13, V–T…