Data Structures & AlgorithmsModerateGATE CS · ICPC regional
A tree has the vertices A, F, I, O, P, U, Y and the edges I–A, I–F, F–U, U–O, F–P, P–Y. What is the minimum number of vertices needed so that every edge has at least one endpoint in the chosen set?
- A. 5
- B. 4
- C. 3
- D. 2
Correct answer: C. 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 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 has vertices with values in brackets: U[-2], B[7], H[5], A[7], N[-2], P[5], C[4], S[-1]. The edges are U–B, U–H, H–A, A–N, B–P…
- An undirected graph has the vertices A, J, Q, T, Y and the edges T–Q, T–A, Y–Q, Y–A, Q–A. What is its chromatic number, the least number…
- A tree has the vertices B, C, D, E, M, P, S, U, V, W and the edges U–B, U–C, C–W, B–V, U–M, M–D, D–P, B–S, W–E. A set D dominates the tree…
- A tree has vertices D, H, J, M, Q, R, U, W and weighted edges (weights in brackets): D–H (9), H–Q (5), H–W (5), Q–M (1), D–U (8), U–J (2)…
- An undirected connected graph on the vertices F, G, Q, S, U has the edges U–G, S–Q, F–Q, U–F, G–S, U–S, S–F, G–Q, U–Q. How many spanning…
- A tree has the vertices A, G, H, I, L, O, P, T, U, Z and the edges G–T, G–U, U–H, H–O, O–Z, Z–P, P–A, A–I, P–L. A set D dominates the tree…