-4

In the interval covering problem, we are given n intervals

[s1,t1), [s2,t2), ···, [sn,tn)

such that

S i∈[n][si,ti) = [0,T).

The goal of the problem is to return a smallest-size set

S ⊆ [n]

such that

S i∈S[si,ti) = [0,T).

Design a greedy algorithm for this problem.

Codor
  • 17,447
  • 9
  • 29
  • 56

1 Answers1

1

A greedy algorithm could be devised as follows. As long as there is a point p in [0,T) which is not contained in one of the already selected intervals, select an interval [s_i,t_i) , which must exist, since the union of all [s_i,t_i) is [0,T) as stated in the requirements. As the set of intervals [s_i,t_i) is finite, this procedure must terminate.

Codor
  • 17,447
  • 9
  • 29
  • 56
  • Thanks for the reply sir but i need a complete solution of this problem – Prashant Srivastava Feb 21 '16 at 16:43
  • then sir I would recommend you log out here and start to work on the problem using the good hint Codor gave – Random Dev Feb 21 '16 at 16:48
  • do you really think anyone will do your homework for you? It's ok to ask hw-questions here but your are expected to show some kind of effort and usually we don't give complete answers as you will learn nothing from it - also: do you think it's a good idea to come in, post your demands and expect your solution *as soon as possible*? – Random Dev Feb 21 '16 at 17:36