Question: Algorithm for Scheduling jobs with penalties problem: Can someone help me describe an algorithm for the following problem? For each 1 job is given by
Algorithm for Scheduling jobs with penalties problem: Can someone help me describe an algorithm for the following problem?
For each 1 job is given by two numbers and , where is the deadline and is the penalty. The length of each job is equal to 1 minute and once the job starts it cannot be stopped until completed. We want to schedule all jobs, but only one job can run at any given time. If job i does not complete on or before its deadline, we will pay its penalty . Design a greedy algorithm to find a schedule such that all jobs are completed and the sum of all penalties is minimized. What is the running time of your algorithm?
I saw some solution (image below) saying that you need to sort the jobs two times?? First time sort it in non decreasing order by penalties?? and then second time sort the jobs again by deadline as well as in non decreasing order?? What does that even mean. Can someone give me an example or explain how they do that? Do you create two separate arrays to sort them twice? Or you sort twice on the same array??

solution in The algorithm is given below: Algorithm: sort the job in terms of penalty in non-decreasing order non in terms of deadline as well in sort the job - decreasing order 3 for every job in the queue hose Peralty is minimum minimum also deadline Pick one is S. See job G. run the for end end
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
