The knapsack problem often applies to resource allocation where there are financial constraints and is studied in fields such as combinatorics, computer science, complexity theory, cryptography, and applied mathematics.The 0-1 knapsack problem is as follows.