Data Structures & AlgorithmsHardCodeforces Div 2 C · GATE CS

A tree has the vertices A, C, M, R, V, Y, Z and the edges C–M, M–A, C–R, A–Y, A–V, R–Z. 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. 3
  2. B. 4
  3. C. 1
  4. D. 2

Correct answer: D. 2

A tree DP over three states per vertex gives 2. A vertex cover (3) is a different quantity, and the leaf count (3) is only a lower-bound heuristic.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic