Professional Documents
Culture Documents
Deliverables
Greedy Paradigm
Interval Scheduling
Huffman compression
Minimizing Lateness
It must be feasible
It must be irrevocable
Similarly if denominations are 1, 10, 21, 34, 70, 100, 350 140 Greedy: 100, 34,
1, 1, 1, 1, 1, 1 Optimal: 70, 70
r1 r2 r3
rk
Let o1, o2, o3, , ok of another optimal solution
o1 o2 o3
ok
Show our approach stays ahead of any other solution
r1 r2 r3
rk
o1 o2 o3
ok
r1 r2 r3
rk
o1 o2 o3
ok
finish(r1) finish(o1)
r2 r3
rk
o2 o3
ok
Merge L1 & L2,: 30 + 20 = 50 comparisons , then merge the list & L3:
50 + 10 = 60 comparisons total number of comparisons: 50 + 60 = 110.
If we represent these with 000 001 010 011 101 111 then only 3 million bits
0 1 00 11 10 11 will give us less then 2 million bits
It will give us the prefix free code. use greedy for making the binary tree and then
assign 0 to every left node and 1 to every right node. The nodes with larger frequency
will be nearer to the root and with lesser frequency will be towards the leaves.
1 2
tj 1 10
dj 100 10
Consider jobs in ascending order of slack dj - tj
1 2
tj 1 10
dj 2 10
T 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
J 1 1 1 2 2 3 4 4 4 4 5 5 5 6 6
D 6 6 6 8 8 9 9 9 9 9L 14 14 14 15 15