Fractional Knapsack Visualizer
Weight capacity (kg)
Add an item
+ Add
Added Items
Item Name
Weight (kg)
Value
Value/Weight Ratio
Visualize
Reset
0/0 kg
sorted = items.sort(by ratio desc); rem = capacity; for item of sorted { if rem <= 0 break; if item.weight <= rem { take item fully; rem -= item.weight; } else { fraction = rem / item.weight; take fraction of item; rem = 0; } }
Items Gallery
Sort by Value/Weight
Result Summary
Total Weight Used
0 kg
0% of capacity
Total Value Gained
0
Combined value from items
Items Used
0
No items selected
Item
Fraction Taken
Weight Used (kg)
Value Added
Totals
0
0