Why it matters
Fractional knapsack shows when greedy wins over 0/1. Understanding shapes technique.
Advertisement
The architecture
Sort by v/w desc.
Take fully while fits.
Take fraction of next.
Advertisement
How it works end to end
Exchange argument.
O(n log n) sort dominates.
0/1: NP-hard-ish (pseudo-poly DP).