Skip to content

Commit

Permalink
knapsack.py : Add Knapsack Problem
Browse files Browse the repository at this point in the history
Greedy Approach to solve the Knapsack Problem

closes NITSkmOS#305
  • Loading branch information
halderjoydeep committed Oct 7, 2018
1 parent 7ce94f9 commit 87d46d7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion knapsack_problem/Python/knapsack.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def knapsack(profit, weight, capacity):
:return: maximum profit and the fraction of items
"""

# array of profit/weight ratio
# ratio is array of profit/weight ratio
ratio = [v / w for v, w in zip(profit, weight)]

# a list of (0, 1, ..., n-1)
Expand Down

0 comments on commit 87d46d7

Please sign in to comment.