Visualize the Fractional Knapsack problem. Watch items sorted by value/weight ratio get packed greedily (including partial fractions) to maximize total value.
Unlike 0/1 Knapsack (DP), you can take fractions of an item here. This allows the greedy approach: always take the item with the highest value-per-weight ratio.
Sort items by value/weight ratio descending. Greedily fill the knapsack: take each item fully if capacity allows, otherwise take the fractional remainder to fill exactly.
At every step, the item with the highest ratio gives the most value per unit of weight. Taking a fraction never wastes capacity. The exchange argument proves this greedy choice is globally optimal.
O(N log N) to sort + O(N) to fill = O(N log N). Compare with 0/1 Knapsack: O(N×W) DP. The fractional version is strictly easier because fractions make the solution space convex.