Skip to content

Added documentation for Knapsack #182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Competitive Coding/Greedy/Knapsack/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 0-1 Knapsack Problem
-------------------------
![](https://upload.wikimedia.org/wikipedia/commons/f/fd/Knapsack.svg)

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.

## Applications
-----------------------------
Knapsack problems appear in real-world decision-making processes in a wide variety of fields:
* Finding the least wasteful way to cut raw materials
* Selection of investments and portfolios
* Selection of assets for asset-backed securitization
* Generating keys for the Merkle–Hellman cryptosystems

## Computational Complexity
--------
* The decision problem form of the knapsack problem is NP-complete
* The optimization problem is NP-hard
* There is a pseudo-polynomial time algorithm using dynamic programming
* Many cases that arise in practice, and "random instances" from some distributions, can nonetheless be solved exactly

![More info](https://en.wikipedia.org/wiki/Knapsack_problem)