Data Structures & AlgorithmsHardCodeforces Div 2 C · GATE CS

An undirected graph has the vertices A, J, K, L, O, Q, X, Y and the edges J–Q, J–Y, J–A, J–O, Q–L, Q–X, K–L, K–O. What is the size of a maximum matching (a largest set of edges with no shared endpoint)?

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

Correct answer: A. 3

Because the graph contains an odd cycle it is not bipartite, so the bipartite shortcut of König's theorem does not apply; the true maximum is 3. Taking edges greedily in the listed order yields only 2, a maximal but not maximum matching.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic