The implementation of the algorithm, the method of dynamic programming.
One of the NP-complete combinatorial optimization problems. Title received from their maximization problem of laying as many valuables in a backpack with the proviso that the total volume (or weight) of all the objects that can fit in a backpack, limited. Problems on startup (knapsack) and its modifications often arise in economics, applied mathematics, cryptography, genetics and logistics in order to find the optimum loading of transport (airplane, train, ship's hold) or warehouse. In general terms, the problem can be stated as follows: in a given set of objects with the properties of the "cost" and the "weight" is required to select a certain number of objects so as to maximize total cost, while respecting the constraints on the total weight.