Data Structures & AlgorithmsHardCodeforces Div 2 C · GATE CS
A tree has the vertices A, C, M, R, V, Y, Z and the edges C–M, M–A, C–R, A–Y, A–V, R–Z. 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. 3
- B. 4
- C. 1
- D. 2
Correct answer: D. 2
A tree DP over three states per vertex gives 2. A vertex cover (3) 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 directed graph with no directed cycles has arcs u→v (weight) : F→S (3), F→N (0), F→C (8), G→X (2), G→C (4), S→X (3), N→X (1), N→C (6)…
- A connected undirected graph has the vertices B, E, G, K, Q, R, S, V and the edges Q–K, K–B, K–G, K–S, G–V, G–R, G–E, S–E, R–E. Parallel…
- Grid with 4 rows and 3 columns (top to bottom). A cell marked G is a gate; '.' is a normal cell: .GG G.G .G. ... Each step, which is a…
- A tree has vertices with values in brackets: P[-4], S[4], V[7], U[1], G[-4], D[1]. The edges are P–S, S–V, V–U, S–G, S–D. A path is any…
- 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 grid has 3 rows and 4 columns with these values (top to bottom): 6389 5169 6136 A path moves between side-adjacent cells (up, down, left…