Skip to content

Latest commit

 

History

History
21 lines (12 loc) · 660 Bytes

README.md

File metadata and controls

21 lines (12 loc) · 660 Bytes

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.