Data Structures & AlgorithmsVery hardGATE CS · Product-company placement

A tree on vertices 1–11 has edges 2–1, 3–2, 4–1, 5–2, 6–3, 7–4, 8–6, 9–8, 10–8, 11–8. What is the size of a maximum independent set (no two chosen vertices adjacent)?

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

Correct answer: A. 7

Tree DP: in(u) = 1 + Σ out(child), out(u) = Σ max(in, out) of children; or greedily take every leaf and delete its parent. Both give 7. Taking the larger colour class of the bipartition (6) is not optimal here.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic