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++