项目作者: ambarmodi

项目描述 :
Implementation of Knapsack problem
高级语言: C
项目地址: git://github.com/ambarmodi/Knapsack-Problem.git
创建时间: 2017-05-26T02:09:16Z
项目社区:https://github.com/ambarmodi/Knapsack-Problem

开源协议:

下载


Knapsack-Problem

Implementation of the following approach to solve the 0-1 knapsack problem.

  1. Brute Force approach
  2. Greedy Approach using
    a. Max Benefit First
    b. Min Weight First
    c.(Max weight First
    d. Max weight/unit First
  3. Dynamic approach.

Instructions to execute:

  1. make (This will compile the code)
  2. To execute the Brute Force Approach -> ./Q1-1_brute_force_knapsack.out {input_file}
  3. To execute the Greedy Approach -> ./Q1-2_greedy_algorithm.out {input_file}
  4. To execute the Dynamic Approach -> ./Q1-3_dynamic_programming_knapsack.out {input_file}
  5. 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