Hello, any help appreciated with following problem. I figured out the
algorithm (I think), just having trouble proving it is optimal.
Suppose we are given n tasks each of which takes 1 unit time to
complete. Suppose further that each task has a deadline by which it
is expected to finish. IF a task is not finished by the deadline, a
standard penalty of $10 is applied. The problem is to find a schedule
of the tasks that minimizes the penalty. Develop a greedy algorithm
to solve the problem. Prove that the algorithm gives an optimal
solution.
The greedy algorithm I came up with is:
you schedule tasks to run in order of earliest deadline that has NOT
passed. Schedule the tasks whose deadline has passed to run in the
end.
let me demonstrate with an example:
task1 -> d1 = 1 (d1 = deadline for task 1)
task2 -> d2 = 1 (d2 = deadline for task 2)
task3 -> d3 = 2 (d3 = deadline for task 3)
The greedy algorithm would scedule the tasks as follows
time = 0 -> run task1
time = 1 -> run task3 (task2 has earlier deadline, but time = d2)
time = 2 -> run task2 ($10 penalty)
How do I prove the greedy solution is the optimal? Can I use
induction or contradiction? If so How?
Thanks
algorithm (I think), just having trouble proving it is optimal.
Suppose we are given n tasks each of which takes 1 unit time to
complete. Suppose further that each task has a deadline by which it
is expected to finish. IF a task is not finished by the deadline, a
standard penalty of $10 is applied. The problem is to find a schedule
of the tasks that minimizes the penalty. Develop a greedy algorithm
to solve the problem. Prove that the algorithm gives an optimal
solution.
The greedy algorithm I came up with is:
you schedule tasks to run in order of earliest deadline that has NOT
passed. Schedule the tasks whose deadline has passed to run in the
end.
let me demonstrate with an example:
task1 -> d1 = 1 (d1 = deadline for task 1)
task2 -> d2 = 1 (d2 = deadline for task 2)
task3 -> d3 = 2 (d3 = deadline for task 3)
The greedy algorithm would scedule the tasks as follows
time = 0 -> run task1
time = 1 -> run task3 (task2 has earlier deadline, but time = d2)
time = 2 -> run task2 ($10 penalty)
How do I prove the greedy solution is the optimal? Can I use
induction or contradiction? If so How?
Thanks
Comment