← Back

💎 Treasure Slicing Cavern

Fractional Knapsack - Greedy by Value/Weight

Capacity

-

Used

0

Remaining

-

Total Value

0

Step

0
🎒 Knapsack
0 / 0 kg
💰 $0
Generate items and fill your knapsack optimally!

📖 Fractional Knapsack

Greedy Strategy: Sort items by value/weight ratio (descending)

• Take items with highest ratio first

• If item doesn't fit fully, take a fraction

Why Greedy Works: Each unit of weight gives maximum value

Time: O(n log n) for sorting