18.04.2013 Views

The.Algorithm.Design.Manual.Springer-Verlag.1998

The.Algorithm.Design.Manual.Springer-Verlag.1998

The.Algorithm.Design.Manual.Springer-Verlag.1998

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Knapsack Problem<br />

Next: Discrete Fourier Transform Up: Numerical Problems Previous: Arbitrary-Precision Arithmetic<br />

Knapsack Problem<br />

Input description: A set of items , where item i has size and value . A knapsack<br />

capacity C.<br />

Problem description: Find the subset that maximizes the value of given that ;<br />

i.e. all the items fit in a knapsack of size C.<br />

Discussion: <strong>The</strong> knapsack problem arises whenever there is resource allocation with financial<br />

constraints. Given a fixed budget, how do you select what things you should buy. Everything has a cost<br />

and value, so we seek the most value for a given cost. <strong>The</strong> term knapsack problem invokes the image of<br />

the backbacker who is constrained by a fixed-size knapsack and so must fill it only with the most useful<br />

items.<br />

<strong>The</strong> typical formulation in practice is the 0/1 knapsack problem, where each item must be put entirely in<br />

the knapsack or not included at all. Objects cannot be broken up arbitrarily, so its not fair taking one can<br />

of coke from a six-pack or opening the can to take just a sip. It is this 0/1 property that makes the<br />

knapsack problem hard, for a simple greedy algorithm finds the optimal selection whenever we are<br />

allowed to subdivide objects arbitrarily. For each item, we could compute its ``price per pound'', and<br />

take as much of the most expensive item until we have it all or the knapsack is full. Repeat with the next<br />

file:///E|/BOOK/BOOK4/NODE145.HTM (1 of 4) [19/1/2003 1:30:33]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!