(Latest Revision:
Nov 19, 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 8.
- 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 8.
Total Weight ----->
obj
# wt val | 0 1 2 3 4 5 6 7 8
__________________________________________________
0 0 0 | 0 0 0 0 0 0 0 0 0
1 2 4 | 0
2 4 9 | 0
3 2 5 | 0
4 3 8 | 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.
============================
- Prepare your solution to the problem, in the form indicated.
- COPY AND PASTE the text of your solution into an e-mail.
- DO NOT attach a file to your e-mail.
- DO copy and paste the text of your solution into the message window of the e-mail.
- DO Make the following exact text the subject line of your e-mail.
CS 4440 Knapsack Problem
- DO copy the exact text above and & PASTE IT IN as the subject line of your e-mail
to make sure it is correct.
- Get it right, or get no credit!
- Send the E-mail to tester2@cs.csustan.edu