Data Structures & AlgorithmsVery hardGATE CS · ICPC regional
A tree has the vertices F, G, J, T, U, W, Y and the edges G–T, T–Y, G–U, Y–J, J–W, W–F. What is the minimum number of vertices needed so that every edge has at least one endpoint in the chosen set?
- A. 5
- B. 3
- C. 2
- D. 4
Correct answer: B. 3
Minimum vertex cover on a tree is computed by a DP over children (taking the parent or all children). It is 3 here. Repeatedly picking the highest-degree vertex gives 3, and the number of non-leaf vertices gives 5.
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 directed graph has the vertices A, E, J, M and the arcs M→E, M→J, M→A, E→A, J→M, J→A, A→M, A→E, A→J. Count the directed Hamiltonian…
- An undirected connected graph on 5 vertices has the edges (weights in brackets, all distinct): A–F (17), S–P (22), F–P (29), A–P (10), A–S…
- An undirected graph has the vertices D, M, P, Q, Y and the edges Q–P, Q–D, P–M, P–Y, M–D. A walk may repeat vertices and edges. How many…
- Starting from the integer 6, one operation either adds 1, subtracts 1, or doubles the current value. Values may be any non-negative…
- A tree has the vertices E, F, G, I, K, N, Y and the edges G–F, G–N, F–E, N–K, K–Y, K–I. A centroid is a vertex whose removal leaves no…
- An undirected graph on 7 vertices has the edges J–P, J–O, J–U, P–O, P–B, P–U, O–S, O–A, O–U, A–U. How many simple paths (no repeated…