Data Structures & AlgorithmsVery hardICPC regional · Codeforces Div2 D
Problem: A tree has 8 nodes numbered 1–8 with edges 1-2, 1-3, 2-4, 2-5, 3-6, 3-7, 7-8. What is the size of a minimum vertex cover (a smallest set of vertices touching every edge)?
- A. 4
- B. 3
- C. 2
- D. 5
Correct answer: B. 3
In a tree, a minimum vertex cover can be found by a tree DP that decides whether each node is included. Choosing a maximal matching's endpoints gives a cover that is only sometimes minimum.
More Coding Interview Problems questions
- Problem: In the directed graph on vertices 1–6 with arcs 1→2, 1→3, 2→4, 3→4, 4→5, 3→6, 6→5, what is the length of the longest directed…
- Problem: A binary tree is given in preorder (root first, then left subtree, then right subtree) as 8, 3, 1, 6, 4, 7, 10, 14, 13 and…
- Problem: For the binary tree with root value 2 and children: 2 has left child 3 and right child 9; 3 has left child 1 and right child 5; 9…
- Problem: The string "banana" has its longest repeated substring (a substring occurring at least twice, overlaps allowed) of length L. What…
- Problem: How many subsequences equal to the string "abc" are contained in "aabbcbcac" (a subsequence picks positions in increasing order…
- Problem: The string "aabcccccaaa" is run-length encoded (each run becomes its letter followed by its run length, e.g. "a2b1..."). What is…