Data Structures & AlgorithmsVery hardCodeforces Div 2 D · ICPC regional
A tree has the vertices D, G, I, J, M, T, X, Y and the edges Y–I, I–J, J–G, J–X, G–T, X–M, Y–D. 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. 4
- B. 3
- C. 2
- D. 5
Correct answer: B. 3
A tree DP over three states per vertex gives 3. A vertex cover (4) is a different quantity, and the leaf count (3) 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
- An undirected graph has the vertices D, E, H, K, L, Q, V, Z and the edges Q–H, Q–V, Q–K, L–Z, L–D, E–V, E–K, Z–V, Z–K, H–K, V–D. What is…
- Two unmarked jugs hold 7 litres and 8 litres. Allowed operations: fill a jug completely, empty a jug completely, or pour one jug into the…
- A pile holds p stones. In one move a player removes exactly s stones, where s is one of {1, 2, 4} and s ≤ the pile size. The player who…
- A tree has the vertices F, G, J, T, U, W, Y and the edges G–T, T–Y, G–U, Y–J, J–W, W–F. What is the minimum number of vertices needed so…
- A directed graph has the vertices A, E, J, M and the arcs M→E, M→J, M→A, E→A, J→M, J→A, A→M, A→E, A→J. Count the directed Hamiltonian…
- An undirected connected graph on 5 vertices has the edges (weights in brackets, all distinct): A–F (17), S–P (22), F–P (29), A–P (10), A–S…