Wednesday, March 19, 2014

Today we will look at some more discussion on greedy algorithms for job scheduling. Upto now we had established two facts :
1) For any job a with profit pa that is in SI and not in SJ, pa >= pb.
2) For common jobs between SI and SJ, they share the same time slot.
So if we transform SI to SI' and SJ to SJ' where they have the same time reference, then for a job a in SI' we should find an empty slot in SJ' because if there was another job there that would have had a different profit which is not possible. We see why this way. Lets say that there was a job b in that empty slot. If its profit was the same as that of a, then the job is the same as a and we maintained the job with profit pa exists only in SI and not in SJ. If b had a profit more than that of a, it would have had a position earlier than a in SI' since they have the same time reference. However this is not possible. Similarly, it cannot have a profit less than for the same reason. Thus we have eliminated one of the jobs from SI' and SJ' while preserving optimality.
Since we can repeat this step multiple times for jobs with highest profit and  we can preserve optimality at each step. Eventually we can transform J to be the same as I. So J is optimal I is the same as J. Hence I is itself optimal. So greedy solution is optimal.
To conclude, we have established that
J can be executed if and only if J can be executed in deadline order
and
Greedy solution is optimal.


No comments:

Post a Comment