0/1 knapsack
mediumLeaving an item inherits the row above; taking it looks back at reduced capacity and adds the value. The arrows show which, and following them back recovers the bag's contents.
Worst
O(n × W)Space O(n × W), or O(W) with the 1-D trickLoading the 0/1 knapsack engine…