Skip to content

Abdallah-Elshamy/knapsack-iterative

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

knapsack-iterative

an iterative solution for the knapsack problem In this programming problem and the next you'll code up the knapsack algorithm from lecture.

Let's start with a warm-up

This file "knapsack1.txt" describes a knapsack instance, and it has the following format:

[knapsack_size][number_of_items]

[value_1] [weight_1]

[value_2] [weight_2]

...

For example, the third line of the file is "50074 659", indicating that the second item has value 50074 and size 659, respectively.

You can assume that all numbers are positive. You should assume that item weights and the knapsack capacity are integers.

find the value of the optimal solution.