Data Structures & AlgorithmsVery hardGATE CS · ICPC regional
A tree has the vertices B, D, E, G, J, O, S, W and the edges S–J, J–D, J–B, B–O, S–G, D–W, G–E. A set D dominates the tree if every vertex is in D or adjacent to a vertex in D. What is the size of a smallest dominating set?
- A. 4
- B. 3
- C. 5
- D. 2
Correct answer: B. 3
A tree DP over three states per vertex gives 3. A vertex cover (4) is a different quantity, and the leaf count (3) is only a lower-bound heuristic.
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 four-wheel combination lock shows four digits 0–9 on wheels that wrap around (9 goes to 0 and 0 goes to 9). One move turns one wheel by…
- A tree has the vertices A, D, E, G, I, L, P, V, W and the edges L–G, L–W, W–P, W–A, A–E, P–D, P–I, L–V. A centroid is a vertex whose…
- A directed acyclic graph has the vertices C, G, K, P, W, X, Z and the arcs Z→X, Z→G, Z→K, C→W, C→K, P→X, P→K, X→W, W→K, G→K. Two players…
- An undirected graph has the vertices H, J, K, N, P, Q, R and the edges K–R, K–P, Q–J, N–R, P–R, N–J, P–J, K–J, Q–R, H–J. How many simple…
- A pile holds p stones. In one move a player removes exactly s stones, where s is one of {2, 3} and s ≤ the pile size. The player who…
- A directed graph has the vertices B, H, L, Q, R, T, U, Z and the arcs B→L, B→H, B→R, B→Q, L→B, L→Z, L→H, Z→B, Z→L, Z→T, H→L, H→U, R→B…