Data Structures & AlgorithmsVery hardGATE CS · TCS NQT

Which minimum number of intervals from [(0,2),(1,4),(3,6),(5,9),(7,10)] are needed to cover the segment [0, 10] completely (the union must include every point from 0 to 10)?

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

Correct answer: B. 5

Greedy: from the covered frontier, always take the interval starting at or before it that reaches furthest. This is the standard exchange argument for covering a line.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic