This is a greedy algorithm for the fractional knapsack problem. The idea is to fill a knapsack with maximum possible weights that will maximize the total benefit. You can visit the following link for the code.
Fractional Knapsack
This is a greedy algorithm for the fractional knapsack problem. The idea is to fill a knapsack with maximum possible weights that will maximize the total benefit. You can visit the following link for the code.
Fractional Knapsack
Another interesting variation of this is the integer knapsack(both 1 and 2 dimensions) . Wish you could throw some light on those. Dynamic programming makes them really interesting!