Data Structures & AlgorithmsVery hardICPC regional · Codeforces Div2 D

Problem: A tree has 8 nodes numbered 1–8 with edges 1-2, 1-3, 2-4, 2-5, 3-6, 3-7, 7-8. What is the size of a minimum vertex cover (a smallest set of vertices touching every edge)?

  1. A. 4
  2. B. 3
  3. C. 2
  4. D. 5

Correct answer: B. 3

In a tree, a minimum vertex cover can be found by a tree DP that decides whether each node is included. Choosing a maximal matching's endpoints gives a cover that is only sometimes minimum.

More Coding Interview Problems questions

Exams that ask this topic