Data Structures & AlgorithmsVery hardGATE CS · ICPC regional
A tree has the vertices B, D, K, O, Q, V, W, Y, Z and the edges D–K, K–W, W–V, D–B, W–Q, V–Y, V–Z, Q–O. 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. 5
- B. 4
- C. 3
- D. 2
Correct answer: C. 3
A tree DP over three states per vertex gives 3. A vertex cover (4) is a different quantity, and the leaf count (4) 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
- Each cell of a grid with 3 rows and 5 columns has an arrow: R = right, L = left, U = up, D = down. RDLLR UUDUR LDUDD From a cell you may…
- A directed graph with no directed cycles has arcs u→v (weight) : U→A (-3), U→V (4), A→Z (3), V→O (2), Z→O (5). Weights may be negative…
- A directed acyclic graph has the vertices C, D, G, J, O, S, T and the directed edges D→J, G→C, G→O, S→O, C→J, D→O, O→J, D→T, C→O, S→C…
- An undirected graph has the vertices B, C, F, L, O, P, Q, R, V, Z and the edges Q–L, Q–Z, Q–V, B–O, B–L, B–Z, B–R, B–P, O–Z, O–F, O–V…
- A grid has 6 rows and 4 columns (top to bottom; '.' open, '#' blocked): .... #... .... #... ..#. ..#. You may only move right or down, and…
- A bipartite graph has left side P1, P2, P3 and right side Q1, Q2, Q3, Q4, Q5, with edges P1–Q5, P1–Q3, P3–Q4, P1–Q2, P2–Q1, P2–Q4, P3–Q3…