CSE408 Vertex Cover and Bin Packing
CSE408 Vertex Cover and Bin Packing
a) 0 b) 1 c) 2 d) 4
Polling
S1 = {6,1,3}, Cost(S1) = 8
S2 = {2,5,4}, Cost(S2) = 7
S3 = {1,4,3,6}, Cost(S3) = 5
1 2
3 4 5
And you have several `bins’ with a max capacity, say 50kg.
1 2
3 4 5
And you have several `bins’ with a max capacity, say 50kg.
5 4
1 2
3
1 2
3 4 5
And you have several `bins’ with a max capacity, say 50kg.
4 5
3
1 2
• Next Fit (NF) always keeps a single open bin. When the new item does not fit
into it, it closes the current bin and opens a new bin.
• Next-k-Fit (NkF) is a variant of Next-Fit, but instead of keeping only one bin
open, the algorithm keeps the last k bins open and chooses the first bin in which
the item fits.
• First-Fit (FF) keeps all bins open, in the order in which they were opened. It
attempts to place each new item into the first bin in which it fits.
• Best-Fit (BF), too, keeps all bins open, but attempts to place each new item into
the bin with the maximum load in which it fits.
Bin-Packing
• Single-class algorithms
– If the item fits into one of the currently open bins, then put it in one of these bins;
– Otherwise, open a new bin and put the new item in it.
• Next Fit (NF) always keeps a single open bin. When the new item does not fit
into it, it closes the current bin and opens a new bin.
• Next-k-Fit (NkF) is a variant of Next-Fit, but instead of keeping only one bin
open, the algorithm keeps the last k bins open and chooses the first bin in which
the item fits.
• First-Fit (FF) keeps all bins open, in the order in which they were opened. It
attempts to place each new item into the first bin in which it fits.
• Best-Fit (BF), too, keeps all bins open but attempts to place each new item into
the bin with the maximum load in which it fits.
• Multiplicative approximation
• Ordering the input list by descending size;
• Put the item in the bins.
Polling
Let U = {1,2,3,8,9,15}
And S1= {8,1,2,9}, Cost = 5
S2 = {15,1,3,8}, Cost = 6
S3= {9,8,2,15}, Cost = 4
Find the minimum cost set cover.
Polling
Choose the packing that results from the use of the first fit (FF) bin-packing
algorithm to pack the following weights into bins that can hold no more than 9
lbs.
4 lbs, 5 lbs, 3 lbs, 2 lbs, 7 lbs, 6 lbs, 4 lbs, 2 lbs
1. a 2. b 3. c 4. Another packing