Skip to content

Commit 4939ad1

Browse files
authored
Merge pull request #182 from imVivekGupta/sort_doc
Added documentation for Knapsack
2 parents 3c6030f + 53c9ef5 commit 4939ad1

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# 0-1 Knapsack Problem
2+
-------------------------
3+
![](https://upload.wikimedia.org/wikipedia/commons/f/fd/Knapsack.svg)
4+
5+
The knapsack problem or **rucksack 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. It derives its name from the problem faced by someone who is constrained by a fixed-size knapsack and must fill it with the most valuable items.
6+
7+
## Applications
8+
-----------------------------
9+
Knapsack problems appear in real-world decision-making processes in a wide variety of fields:
10+
* Finding the least wasteful way to cut raw materials
11+
* Selection of investments and portfolios
12+
* Selection of assets for asset-backed securitization
13+
* Generating keys for the Merkle–Hellman cryptosystems
14+
15+
## Computational Complexity
16+
--------
17+
* The decision problem form of the knapsack problem is NP-complete
18+
* The optimization problem is NP-hard
19+
* There is a pseudo-polynomial time algorithm using dynamic programming
20+
* Many cases that arise in practice, and "random instances" from some distributions, can nonetheless be solved exactly
21+
22+
![More info](https://en.wikipedia.org/wiki/Knapsack_problem)

0 commit comments

Comments
 (0)