Data Structures & AlgorithmsHardGATE CS · Codeforces Div 2 B
An undirected graph has the vertices D, E, H, M, O, P, U, V and the edges H–O, H–M, H–D, H–V, O–E, O–V, O–P, M–U, M–V, E–D, E–U, D–U, D–V, D–P, U–V. What is the size of a maximum matching (a largest set of edges with no shared endpoint)?
- A. 4
- B. 5
- C. 6
- D. 3
Correct answer: A. 4
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 4. Taking edges greedily in the listed order yields only 3, a maximal but not maximum matching.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- An undirected connected graph on the vertices B, H, O, P, S has the edges H–S, O–B, S–P, H–P, S–B, B–P, H–B. How many spanning trees does…
- A tree has vertices A, C, G, J, N, Q, X, Y and weighted edges (weights in brackets): Y–Q (2), Y–X (5), Y–J (2), J–C (2), C–A (8), X–G (7)…
- Two unmarked jugs hold 5 litres and 7 litres. Allowed operations: fill a jug completely, empty a jug completely, or pour one jug into the…
- A connected undirected graph has the vertices B, H, J, P, Q, V, Z and weighted edges (weights in brackets): J–H (11), Q–P (16), B–P (9)…
- An undirected graph on 5 vertices has the edges C–J, C–D, C–P, J–D, J–P, D–P, P–Z. How many simple paths (no repeated vertex) go from C to…
- Consider this function: python def g(n): if n < 2: return n if n % 2 == 0: return g(n - 3) + g(n - 3) return g(n - 3) - 1 What value does…