Data Structures & AlgorithmsModerateGATE CS · ICPC regional
A tree has the vertices C, F, G, I, N, R, S and the edges R–G, R–S, S–I, I–C, C–F, R–N. 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. 2
- B. 4
- C. 1
- D. 3
Correct answer: A. 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 tree has the vertices B, C, F, K, M, N, Q, R, X, Z and the edges C–X, X–Z, X–M, M–K, C–B, Z–R, B–Q, M–N, N–F. What is the minimum number…
- A tree has vertices with values in brackets: M[0], R[5], A[9], G[-4], H[9]. The edges are M–R, M–A, R–G, M–H. A path is any sequence of…
- Bellman–Ford is run from source P on the directed graph whose arcs (weights in brackets) are listed in the order they are relaxed: Z→S…
- A directed graph has the vertices F, J, N, P, R, Z and the arcs P→F, P→Z, P→N, J→N, R→P, F→P, F→R, Z→P, Z→N, N→F, N→Z. How many strongly…
- Grid with 4 rows and 4 columns (top to bottom). A cell marked G is a gate; '.' is a normal cell: ...G .GGG GG.G G... Each step, which is a…
- A connected undirected graph has the vertices A, B, E, J, M and weighted edges (weights in brackets): M–E (8), A–E (17), M–B (10), A–B…