Data Structures & AlgorithmsHardGATE CS · ICPC regional
A bipartite graph has left side P1, P2, P3, P4 and right side Q1, Q2, Q3, with edges P4–Q2, P3–Q3, P4–Q3, P1–Q3, P2–Q1, P4–Q1. What is the size of a maximum matching (the largest set of edges with no shared endpoint)?
- A. 6
- B. 2
- C. 3
- D. 4
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 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
- Consider this recursive function: python def f(n): if n <= 1: return f(n - 2) if n % 2 == 0: f(n - 3) How many times is f called in total…
- An undirected graph has the vertices E, G, I, L and the edges G–I, G–E, I–L, L–E. A walk may repeat vertices and edges. How many walks of…
- A directed acyclic graph has the vertices D, F, I, P, R, X, Y and the directed edges I→F, Y→F, R→P, X→P, Y→D, D→P, X→D, R→F, Y→X. How many…
- Consider this recursive function: python def f(n): if n <= 0: return f(n - 2) if n % 3 == 0: f(n - 2) How many times is f called in total…
- An undirected graph has the vertices K, L, N, P, Q, R and the edges P–K, K–N, R–Q, R–N, N–L, N–Q, K–L, P–N. How many simple cycles does it…
- A tree has the vertices A, D, E, L, P, V, X and the edges X–D, X–P, X–E, D–V, E–L, P–A. What is the minimum number of vertices needed so…