WIS problem:
Given:
Suppose we are to schedule print jobs on a printer. Each job
has a weight
(representing how important the job is) and a processing time
(representing how long the job takes). A schedule is an ordering
of the jobs.
For a given schedule
, let
be the finishing time of job
in the schedule.
Want:
Design a greedy algorithm that computes a schedule with minimum weighted average finishing time that minimizing
.
Solve:
Our greedy algorithm can be sorting the jobs in increasing
order.
Assume for simplicity that no 2 jobs have the same ratio. To prove that the schedule is OPT, we resort to the usual exchange argument.
Suppose the OPT is
and there are 2 adjacent indices
and
such that:

Now, consider:

where we swap the position of
and
, and leave other jobs in their places. We now need to prove the change decreases the cost of the schedule.
Notice that the finishing time of jobs other than
and
is the same in
and
. Thus:



Let
. Then:




Plug those values into expression from above for the difference in cost between
and
. After simplifying we get:

Noting that

implies
. so we get:

Thanks