GATE Computer ScienceHardGATE CS (PYQ pattern)

The closed intervals [1,4], [2,6], [3,5], [7,10], [8,12], [9,11], [13,15], [5,8], [10,14], [0,2] are given. What is the minimum number of points on the line such that every interval contains at least one chosen point?

  1. A. 4
  2. B. 3
  3. C. 5
  4. D. 6

Correct answer: A. 4

Greedy: sort by right endpoint and pick the right endpoint of the first uncovered interval: points 2, 5, 10, 15 (the last for [13,15]). A brute force over all 3-point sets confirms that fewer than 4 points cannot stab all ten intervals.

More Algorithms questions

Exams that ask this topic