https://github.com/gervinfung/knapsackproblem
Do you know how to solve the knapsack? Come and find out how to solve Knapsack in 5 different ways. Time/Space Complexity included
https://github.com/gervinfung/knapsackproblem
branch-and-bound bruteforce dynamic-programming genetic-programming knapsack-problem-dynamic knapsack-problem-genetic knapsack01 leat-cost-branch-and-bound memoization
Last synced: about 1 year ago
JSON representation
Do you know how to solve the knapsack? Come and find out how to solve Knapsack in 5 different ways. Time/Space Complexity included
- Host: GitHub
- URL: https://github.com/gervinfung/knapsackproblem
- Owner: GervinFung
- Created: 2020-12-23T12:48:03.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-06-11T09:47:48.000Z (about 5 years ago)
- Last Synced: 2025-02-05T11:19:02.806Z (over 1 year ago)
- Topics: branch-and-bound, bruteforce, dynamic-programming, genetic-programming, knapsack-problem-dynamic, knapsack-problem-genetic, knapsack01, leat-cost-branch-and-bound, memoization
- Language: Java
- Homepage:
- Size: 38.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Solving 0/1 Knapsack Problem in 5 different ways
NOTE:
1. *Algorithm contains items chosen as well, so the time complexity would be different from conventional algorithms* 2. *Do correct me if I am wrong*
**n = Number Of Items && w = Weight of Items**
**N = Number Of Generations && P = Number Of Populations**
Name of Algorithms|Best|Average|Worst|Space Complexity|
| --- | --- | --- | --- | --- |
Dynamic Programming|Ω(n)|Θ(n)|O(n)|O(n)|
Least Cost Branch & Bound|O(n)| O(n) ~ O(2 ^ n) |O(2)|O(n)|
Memoize|Ω(nW log(n))|Θ(nW log(n))|O(nW log(n))|O(nW)
Brute Force|Ω(2n ^ n)|Θ(2n ^ n)|O(2n ^ n)|O(n)|
Genetic Programming|Ω(NP)|Θ(NP)|O(NP)|O(NP)|