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?

  1. A. 6
  2. B. 3
  3. C. 5
  4. 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.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic