Skip to content

C++ implementation of the 0/1 knapsack problem with item keep tracking

Notifications You must be signed in to change notification settings

gazben/knapsack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

knapsack

This is a C++ implementation of the 0/1 knapsack problem.

The example solves this problem: https://www.youtube.com/watch?v=EH6h7WA7sDw

Output of the example problem:

Knapsack current state
Size: 5 Item count: 3
{ Weight: 3, Value: 5 }
{ Weight: 2, Value: 3 }
{ Weight: 1, Value: 4 }

Value matrix: 
V   1 2 3 4 5 
    - - - - -
0 | 0 0 0 0 0 
1 | 0 0 5 5 5 
2 | 0 3 5 5 8 
3 | 4 4 7 9 9 

Keep matrix: 
K   1 2 3 4 5 
    - - - - -
0 | 0 0 0 0 0 
1 | 0 0 1 1 1 
2 | 0 1 0 0 1 
3 | 1 1 1 1 1 

About

C++ implementation of the 0/1 knapsack problem with item keep tracking

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published