Fractional knapsack
A knapsack where you can take a piece of an item and earn the matching share of its value.
Example
If a 4 kg cheese is worth $12 and 1 kg is free, you take 1 kg and add $3.
Test yourself: Fractional knapsack
Fractional knapsack
In the fractional knapsack you can take a ___ of an item.
With a 4 kg cheese worth $12, taking 1 kg adds $3: a quarter of the value.
Fractional knapsack
A 5 kg item worth 40 has a value per kilo of ___.
40 ÷ 5 = 8: each kilo taken adds 8.
Fractional knapsack
Filling the knapsack is covering a fixed width with as much ___ as possible.
With width 6, putting the tallest bars first gives area 31; starting with C, the shortest, gives less.
0/3
â–¶ Play