(Latest Revision:
Mar 30, 2021)
Knapsack Problem
- Fill out the table given below for a knapsack problem, where the objects, weights,
and values are as given, and the overall weight limit is 9.
- Next, put an asterisk (*) after the entries in the table that are used
when backtracking to find objects to use in the solution.
- Then list the numbers of the objects that can be used
for an optimal solution.
- Also list the weights and values of those objects.
- Verify that the values of your solution objects add up to the optimal number
in the last row and column in the table.
- Verify that the sum of the weights of your solution objects is not
more than the overall weight limit of 9.
Total Weight ----->
obj
# wt val | 0 1 2 3 4 5 6 7 8 9
______________________________________________________
0 0 0 | 0 0 0 0 0 0 0 0 0 0
1 5 17 | 0
2 2 16 | 0
3 4 7 | 0
4 8 13 | 0
5 7 19 | 0
Let me know if you have questions about how such problems are solved.
The algorithm is covered in section 6.4.
Directions For Submitting Solution:
You will e-mail me your homework solution.
Below is a sample of the information I want in your e-mail. It shows what the information would be
for an example problem. You must give me the same kind of information, in the same format,
for your assigned problem.
============================
Total Weight ----->
obj
# wt val | 0 1 2 3 4 5 6 7
_____________________________________________
0 0 0 | 0* 0 0 0 0 0 0 0
1 1 2 | 0* 2 2 2 2 2 2 2
2 4 9 | 0 2 2 2 9* 11 11 11
3 3 7 | 0 2 2 7 9 11 11 16*
4 2 3 | 0 2 3 7 9 11 12 16*
Objects to use in optimal solution: 3 (wt=3;v=7), 2 (wt=4;v=9)
The sum of values of items 3 and 2 is 7+9=16, which is the last entry in the table, as it should be.
The sum of weights of items 3 and 2 is 3+4=7, which does not exceed the weight limit of 7.
============================
When you create your e-mail, copy and paste the text of your solution into the e-mail.
Do not attach any files to your e-mail.
Copy and paste the text into the message window of the e-mail.
Send the e-mail to
tester2@cs.csustan.edu
with this subject line:
CS 4440 Knapsack Problem
(Copy & Paste that exact subject line. Get it right, or get no credit.)