Data Structures & AlgorithmsVery hardProduct-company placement
A tree on vertices 1–10 has edges 2–1, 3–1, 4–2, 5–2, 6–4, 7–6, 8–3, 9–7, 10–8. What is the size of a minimum DOMINATING set (every vertex is in the set or adjacent to one in it)?
- A. 5
- B. 4
- C. 3
- D. 2
Correct answer: C. 3
Greedy from the leaves up: a leaf's parent must be chosen (or the leaf dominated otherwise), then remove what it dominates and repeat; this gives 3. A minimum vertex cover (size 5) is a different problem.
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
- What is the length of the longest BITONIC subsequence (strictly increasing then strictly decreasing; either part may be empty) of [13, 15…
- Unit-time jobs (deadline, profit): J1 (2, 63), J2 (1, 38), J3 (2, 38), J4 (4, 52), J5 (2, 86), J6 (1, 75), J7 (1, 40). One job runs at a…
- A rooted tree has 7 nodes with 1 child, 2 nodes with 2 children, 4 nodes with 3 children, 8 nodes with 4 children, and every other node is…
- In how many ways can a convex polygon with 7 vertices be divided into triangles by non-crossing diagonals?
- Coins of denominations 1, 2, 8, 10 are available in unlimited supply. What is the minimum number of coins needed to make 16, and how many…
- Heap sort (ascending) is run on [3, 13, 29, 24, 7, 25, 19, 40]: build a max-heap bottom-up, then repeatedly swap the root with the last…