© xkcd.com
Knapsack problem algorithms for JavaScript. See docs.
import {
knapsackGreedy,
knapsackApprox,
} from '@problem-solving/knapsack';
knapsackGreedy(n, v, w, W); // 1/2 approximation
knapsackApprox(eps, n, v, w, W); // 1-eps approximation
- The knapsack problem explained at Wikipedia.