GATE Computer ScienceVery hardGATE CS (PYQ pattern)
The standard 2-approximation for Vertex Cover scans the edges in the order 0-1, 1-2, 2-3, 3-4, 4-5, 5-6, 1-4, 2-5 and, whenever an edge has no endpoint in the cover, adds both of its endpoints. What is the size of the cover it returns? (An optimal cover has size 3.)
- A. 3
- B. 4
- C. 5
- D. 6
Correct answer: D. 6
Edge 0-1 adds {0,1}; 1-2 is covered; 2-3 adds {2,3}; 3-4 covered; 4-5 adds {4,5}; the rest are covered. The cover is {0,1,2,3,4,5} of size 6, exactly twice the optimum 3 (the matching bound is tight here).
More Algorithms questions
- Items 0.5, 0.7, 0.5, 0.2, 0.4, 0.2, 0.5, 0.1, 0.6 (in this order) are packed into bins of capacity 1 by Next-Fit, First-Fit and…
- Longest-Processing-Time-first scheduling puts jobs, in non-increasing order of length, on the currently least loaded machine. For jobs of…
- For the string s = abaababaabaab (13 characters), a number p (1 ≤ p ≤ 13) is called a period if s[i] = s[i + p] for every valid i (p = 13…
- Boyer–Moore majority vote (candidate c and counter k; if k = 0 take the current element as c with k = 1; else increment k when equal and…
- In the Josephus problem 30 people numbered 1 to 30 stand in a circle; counting starts at person 1 and every third person is eliminated (3…
- Quicksort partitions m elements with exactly m − 1 comparisons and then recurses on the two sides (sizes k and m − 1 − k). Over all inputs…