Fractional knapsack
The fractional knapsack is like the 0-1: n items with weight and value, and a capacity. Each item is chosen once, but you can take just a part of it, and earn the matching share of its value. If a 4 kg cheese is worth $12 and 1 kg is free, you take 1 kg and add $3. That changes everything: dynamic programming is no longer needed and a greedy is enough.
The key is the value per kilo: val[i − 1] ÷ wgt[i − 1]. If you take a piece of w kilos, it adds w × val[i − 1] ÷ wgt[i − 1]. For example: A weighs 2 and is worth 10, 5 per kilo; B weighs 3 and is worth 18, 6 per kilo; C weighs 4 and is worth 12, 3 per kilo. To get the most from each kilo of knapsack, B is best, then A and then C.
There is a way to see it with a drawing. Each item is a bar: its width is its weight and its height, its value per kilo. The bar's area is its value. Filling the knapsack is covering a fixed width, the capacity, with as much area as possible. If the tallest bars go first, each unit of width gets the greatest height available. With capacity 6: 3 wide at height 6, 2 at height 5 and 1 at height 3, area 18 + 10 + 3 = 31.
