Data Structures & AlgorithmsHardGATE CS · Codeforces Div2 C

A tree has these parent→child edges: 40→98, 84→32, 22→82, 68→16, 42→57, 68→42, 42→23, 28→40, 98→84, 82→68, 98→22. A vertex cover is a set of vertices such that every edge has at least one endpoint in the set. What is the size of a minimum vertex cover?

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

Correct answer: A. 5

In a tree the minimum vertex cover equals the maximum matching (König's theorem), found greedily from the leaves up. Counting leaves or internal nodes is a common misreading, not the optimum.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic