Data Structures & AlgorithmsVery hardGATE CS · Codeforces Div 2 B
A tree has the vertices D, F, I, O, Q, R, S, U, X and the edges I–S, I–U, I–O, I–D, D–X, D–F, U–Q, X–R. What is the minimum number of vertices needed so that every edge has at least one endpoint in the chosen set?
- A. 6
- B. 3
- C. 4
- D. 5
Correct answer: C. 4
Minimum vertex cover on a tree is computed by a DP over children (taking the parent or all children). It is 4 here. Repeatedly picking the highest-degree vertex gives 4, and the number of non-leaf vertices gives 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 tree on the vertices E, H, K, S, U, X has the arcs E→S, S→H, H→K, U→H, X→K (each undirected edge is directed as shown). You may reverse…
- A directed graph has the vertices E, G, L, N, U and the arcs N→L, N→E, N→G, L→N, L→E, U→N, U→L, U→E, U→G, E→L, E→U, E→G, G→U, G→E. Count…
- A connected undirected graph has the vertices A, I, J, N, O, X, Z and the edges A–X, A–O, X–O, X–I, O–Z, O–N, I–N, I–J. How many bridges…
- An undirected graph has the vertices D, G, L, Q, R, X, Y and the edges R–G, Y–R, L–X, Y–G, D–R, Y–L, D–G. How many simple cycles does it…
- Grid with 3 rows and 3 columns (top to bottom). A cell marked G is a gate; '.' is a normal cell: .G. G.. ... Each step, which is a move to…
- Two unmarked jugs hold 7 litres and 9 litres. Allowed operations: fill a jug completely, empty a jug completely, or pour one jug into the…