instructor neelima gupta instructor: ms. neelima gupta

Download Instructor Neelima Gupta Instructor: Ms. Neelima Gupta

If you can't read please download the document

Upload: felicia-johnston

Post on 17-Jan-2018

234 views

Category:

Documents


0 download

DESCRIPTION

Interval/Job Scheduling –a greedy approach

TRANSCRIPT

Instructor Neelima Gupta Instructor: Ms. Neelima Gupta Interval/Job Scheduling a greedy approach Weighted Interval Scheduling Each job i has (s i, f i, p i ) starting time s i, finishing time f i, and profit p i Aim: Find an optimal schedule of job that makes the maximum profit. Greedy approach : choose the job which finishes first..does not work. So, DP Thanks to Neha (16) iS i F i P i Thanks to Neha (16) Weighted Interval Scheduling Time 0 P(1)=10 P(3)=4 P(4)=20 P(2)= P(5)=2 Thanks to Neha (16) Greedy Approach Time 0 P(1)=10 P(4)=20 P(2)= P(5)=2. Thanks to Neha (16) Greedy does not work Time 0 P(1)=10 P(4)=20 P(2)= P(5)=2 Optimal schedule Schedule chosen by greedy app Greedy approach takes job 2, 3 and 5 as best schedule and makes profit of 7. While optimal schedule is job 1 and job4 making profit of 30 (10+20). Hence greedy will not work Thanks to Neha (16) DP Solution for WIS Let m[j]= optimal schedule solution from the first j th jobs, (jobs are sorted in the increasing order of their finishing times) p j =profit of j th job. p[j] =largest index i