mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-11-10 11:09:43 +08:00
Add knapsack problem.
This commit is contained in:
parent
4474d8909f
commit
80433eb36f
@ -40,6 +40,7 @@
|
||||
* [Longest Common Subsequence](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/sets/longest-common-subsequnce) (LCS)
|
||||
* [Longest Increasing subsequence](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/sets/longest-increasing-subsequence)
|
||||
* [Shortest Common Supersequence](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/sets/shortest-common-supersequence) (SCS)
|
||||
* [Knapsack Problem](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/sets/knapsack-problem)
|
||||
* **String**
|
||||
* [Levenshtein Distance](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/string/levenshtein-distance) - minimum edit distance between two sequences
|
||||
* [Hamming Distance](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/string/hamming-distance) - number of positions at which the symbols are different
|
||||
@ -94,7 +95,7 @@
|
||||
* [Longest Common Substring](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/string/longest-common-substring)
|
||||
* [Longest Increasing subsequence](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/sets/longest-increasing-subsequence)
|
||||
* [Shortest Common Supersequence](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/sets/shortest-common-supersequence)
|
||||
* Knapsack problem
|
||||
* [Knapsack Problem](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/sets/knapsack-problem)
|
||||
* Maximum subarray
|
||||
* Maximum sum path
|
||||
* Integer Partition
|
||||
|
23
src/algorithms/sets/knapsack-problem/README.md
Normal file
23
src/algorithms/sets/knapsack-problem/README.md
Normal file
@ -0,0 +1,23 @@
|
||||
# Knapsack Problem
|
||||
|
||||
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.
|
||||
|
||||
Example of a one-dimensional (constraint) knapsack problem:
|
||||
which boxes should be chosen to maximize the amount of money
|
||||
while still keeping the overall weight under or equal to 15 kg?
|
||||
|
||||
![knapsack problem](https://upload.wikimedia.org/wikipedia/commons/f/fd/Knapsack.svg)
|
||||
|
||||
## References
|
||||
|
||||
- [Wikipedia](https://en.wikipedia.org/wiki/Knapsack_problem)
|
||||
- [YouTube](https://www.youtube.com/watch?v=8LusJS5-AGo)
|
Loading…
Reference in New Issue
Block a user