To Prove The Greedy Solution Is Optimal
To Prove The Greedy Solution Is Optimal
Let X =< x1, x2. . . . . xn > denote the greedy solution vector, where xi, 0 xi 1 is the
fraction of Oi that is included in the knapsack.
As per the description of the greedy algorithm, 0 or more of the Xi s will be 1, followed by
a fractional quantity, followed by 0s.
Let j be the rst index such that xj != 1. Then xi = 1, i = 1, 2. . . . , j 1 and xi = 0, i = j
+ 1, j + 2, . . . , n.
Let Y =< y1, y2. . . . . yn > denote an arbitrary optimal solution vector. We will show that Y
can be gradually transformed into X, without decreasing protability, while maintaining
feasibility.
ai (task) :
1 2 3 4 5 6 7
di (deadline) :4 2 4 3 1 4 6
wi (weight) : 70 60 50 40 30 20 10