APPENDIIX F The Knapsack Allgorriitthm

The most famous of the fallen contenders is the trapdoor knapsack proposed by Ralph Merkle [MERK78]. The knapsack problem deals with determining which objects are in a container, such as a knapsack. A simple example is shown if Figure F.1 [HELL78]. The knapsack is filled with a subset of the items shown, whose weights in grams are indicated. Given the weight of the filled knapsack, 1156 grams, the problem is to determine which of the items are contained in the knapsack. (The scale is calibrated to deduct the weight of the empty knapsack.) As an exercise, the reader is encouraged to determine the contents of the knapsack by trail-and-error calculation.