# Interval scheduling scheduling problem with minimal workers

I am writing a greedy algorithm for a variation of the interval scheduling problem that I haven't seen before.

I have a set of jobs, each with start and finish time. All jobs in set must be assigned to a worker, workers cannot have overlapping jobs. My greedy algorithm should minimise workers - use the least number of workers possible to complete all jobs.

Does this algorithm accomplish this? It seems too simple to me and I have probably neglected to think of something.

sort(jobs) //earliest starting time first

w = 0 //number of allocated workers

for i = 1 to n {
if (worker w has no job with finish time later than starting time of job i)
schedule(worker w, job i)
else
schedule(worker w+1, job i)
w++

• What have you tried? We expect you to make a significant effort before asking: e.g., to search/research whether this has been studied before. In your case, you want to know whether a particular algorithm gives the optimal answer: well, have you tried running on your algorithm on a bunch of test cases to see whether it gives the optimal answer on all of them? That's usually the first step in checking whether a greedy algorithm might plausibly work. – D.W. May 4 '15 at 17:05

Given intervals $(s_i, f_i)$, assign them to processors/workers so that you schedule every interval and use the smallest number of processors/workers.