Data Structures & AlgorithmsHardCodeforces Div 2 C · GATE CS
A bipartite graph has left side P1, P2, P3 and right side Q1, Q2, Q3, Q4, with edges P2–Q1, P2–Q3, P1–Q4, P1–Q3, P2–Q4, P3–Q2. What is the size of a maximum matching (the largest set of edges with no shared endpoint)?
- A. 4
- B. 3
- C. 2
- D. 6
Correct answer: B. 3
Augmenting paths (Kuhn's algorithm) reach a matching of size 3. Greedy matching that takes the first free neighbour for each left vertex gets 3, and the smaller side only bounds the matching at 3.
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
- A four-wheel combination lock shows four digits 0–9 on wheels that wrap around (9 goes to 0 and 0 goes to 9). One move turns one wheel by…
- A tree has vertices with values in brackets: X[-1], L[8], G[-1], S[7], F[8], K[6]. The edges are X–L, L–G, X–S, X–F, S–K. A path is any…
- An undirected graph has the vertices A, G, H, L, P and the edges L–G, H–P, A–H, H–G, H–L, A–P, P–G. How many simple cycles does it contain…
- A grid has 4 rows and 7 columns (top to bottom; '.' open, '#' blocked): .#.##.. ..#..#. .....#. ....... You may only move right or down…
- A directed weighted graph has the arcs u→v (weight): F→K (4), F→U (1), F→H (13), K→F (12), U→F (13), U→K (4), U→L (8), L→F (2), L→K (2)…
- A connected undirected graph has the vertices C, K, L, P, U, X, Y and the edges L–X, X–C, X–Y, C–K, C–P, C–U, K–Y, K–P, Y–U, P–U. Parallel…