31 - Knapsack Problem - Definition

@Rishi Srivastava The knapsack problem is a problem in combinatorial optimization: Given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible. The problem often arises in resource allocation where the decision-makers have to choose from a set of non-divisible projects or tasks under a fixed budget or time constraint, respectively. Problem You are given n objects, a knapsack of capacity c, array v, and array w. The ith object has value v[i] and weight w[i]. Determine the maximum total value that you can get by selecting objects in such a manner that their sum of weights is not greater than the capacity c. Github: Hacker Earth:
Back to Top