Data Structures & AlgorithmsHardCodeforces Div 2 C · GATE CS
A tree has the vertices A, C, D, F, G, M, P, S, X, Y and the edges A–M, A–S, M–Y, A–F, M–D, D–X, Y–C, F–G, S–P. A set D dominates the tree if every vertex is in D or adjacent to a vertex in D. What is the size of a smallest dominating set?
- A. 6
- B. 3
- C. 5
- D. 4
Correct answer: D. 4
A tree DP over three states per vertex gives 4. A vertex cover (5) is a different quantity, and the leaf count (4) is only a lower-bound heuristic.
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 grid has 5 rows and 7 columns (rows listed top to bottom; '.' is an open cell, '#' a wall): .#..... ....#.. .#####. .#..... ..#…
- A connected undirected graph has the vertices D, H, J, K, L, T and the edges J–L, J–D, J–H, D–K, D–T, K–T, T–H. How many bridges does it…
- A tree has the vertices D, E, G, H, I, T, U, X, Z and the edges D–T, D–H, T–G, H–E, E–X, D–Z, T–U, Z–I. What is the minimum number of…
- An undirected graph has the vertices E, J, K, M, X and the edges X–M, X–K, X–J, M–J, K–J, K–E. A walk may repeat vertices and edges. How…
- Cities I, P, S, U, X are joined by roads with these travel costs: U–S 12, U–I 1, U–P 20, U–X 18, S–I 11, S–P 13, S–X 7, I–P 19, I–X 6, P–X…
- An undirected connected graph on 5 vertices has the edges (weights in brackets, all distinct): J–I (26), C–W (25), X–W (27), I–W (24), I–X…