Data Structures & AlgorithmsVery hardCodeforces Div 2 D · ICPC regional
A bipartite graph has left side P1, P2, P3, P4 and right side Q1, Q2, Q3, Q4, Q5, with edges P1–Q1, P3–Q1, P3–Q5, P1–Q5, P2–Q3. What is the size of a maximum matching (the largest set of edges with no shared endpoint)?
- A. 5
- B. 4
- C. 3
- D. 2
Correct answer: C. 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 4.
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 connected undirected graph has the vertices A, E, G, J, P, Q, Z and the edges Z–P, Z–J, Z–E, Z–A, P–J, P–G, J–E, A–Q. How many bridges…
- An undirected graph has the vertices A, B, J, Q, Y and the edges Q–J, Q–B, Y–J, Y–B, A–J. A walk may repeat vertices and edges. How many…
- Consider this recursive function: python def f(n): if n <= 1: return f(n - 1) if n % 2 == 0: f(n - 3) How many times is f called in total…
- A counter starts at 1. Each step, you may add 1, add 2, or double the counter. Each step must stay at or below 24. Two sequences of steps…
- Floyd–Warshall runs on vertices 1 to 4 with these arcs u→v (weight): 1→4 (4), 2→1 (1), 2→3 (4), 3→1 (5), 3→4 (10), 4→1 (6), 4→2 (6), 4→3…
- A counter starts at 1. Each step, you may add 1, add 2, or double the counter. Each step must stay at or below 17. Two sequences of steps…