项目作者: ambarmodi
项目描述 :
Implementation of Knapsack problem
高级语言: C
项目地址: git://github.com/ambarmodi/Knapsack-Problem.git
Knapsack-Problem
Implementation of the following approach to solve the 0-1 knapsack problem.
- Brute Force approach
- Greedy Approach using
a. Max Benefit First
b. Min Weight First
c.(Max weight First
d. Max weight/unit First - Dynamic approach.
Instructions to execute:
- make (This will compile the code)
- To execute the Brute Force Approach -> ./Q1-1_brute_force_knapsack.out {input_file}
- To execute the Greedy Approach -> ./Q1-2_greedy_algorithm.out {input_file}
- To execute the Dynamic Approach -> ./Q1-3_dynamic_programming_knapsack.out {input_file}
- make clean . (Cleans the executable)
Note the input-file.txt should include the number of elements in the first line, weights in the second line, profits in the third line, and knapsack capacity in the fourth line.
Sample input file :
3
5, 20, 10
50, 140, 60
30