  Knapsack ProblemThis exercise is due Tuesday, May 14. It has to be turned in on time in order to get participation credit. I'll come into class and go over the solution right away. Then I will collect your work onthe exercise. Be ready to turn it in at that time. Fill out the table for the knapsack problem, where the objects weights, and values are as given and the overall weight limit is 10Next, circle the entries in the table that are used when backtracking to find objects to use in the solution.Then list the object numbers that can be used for an optimal solution.Also list the weights and values of those objectsVerify that the values of your solution objects add up to the optimal number in the last row and column in the tableVerify that the sum of the weights of your solution the objects is not more than the overall weight limit of 10Weight Capacity -wt val1 2 3 4 5 6 789 10Here is a filled-out table for a similar problem:Total Weight --#wtval 1 0 1 2 3 4 5 60 2 2 2 2 2 2 20 2 3 7 9 11 12 16Let me know in class if you have questions about how such problems are solved. The algorithm is covered in section 6.4

Question

Knapsack Problem

This exercise is due Tuesday, May 14. It has to be turned in on time in order to get participation credit. I'll come into class and go over the solution right away. Then I will collect your work on the exercise. Be ready to turn it in at that time.

• Fill out the table for the knapsack problem, where the objects, weights, and values are as given, and the overall weight limit is 10.
• Next, circle the entries in the table that are used when backtracking to find objects to use in the solution.
• Then list the object numbers 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 the objects is not more than the overall weight limit of 10.

Weight Capacity ----->

obj

#  wt val   |  0   1   2   3   4   5   6   7   8   9  10

_________________________________________________________

0  0   0   |   0   0   0   0   0   0   0   0   0   0   0

1  4   5   |   0

2  3   4   |   0

3  5   7   |   0

4  3   2   |   0

Here is a filled-out table for a similar 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

Let me know in class if you have questions about how such problems are solved. The algorithm is covered in section 6.4. help_outlineImage TranscriptioncloseKnapsack Problem This exercise is due Tuesday, May 14. It has to be turned in on time in order to get participation credit. I'll come into class and go over the solution right away. Then I will collect your work on the exercise. Be ready to turn it in at that time . Fill out the table for the knapsack problem, where the objects weights, and values are as given and the overall weight limit is 10 Next, circle the entries in the table that are used when backtracking to find objects to use in the solution. Then list the object numbers 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 the objects is not more than the overall weight limit of 10 Weight Capacity - wt val 1 2 3 4 5 6 789 10 Here is a filled-out table for a similar problem: Total Weight -- #wtval 1 0 1 2 3 4 5 6 0 2 2 2 2 2 2 2 0 2 3 7 9 11 12 16 Let me know in class if you have questions about how such problems are solved. The algorithm is covered in section 6.4 fullscreen
Step 1

Instructions for completing the table:

• Enter 0 where objects and weights are zero.
• For each row assume there are only that objects are present as the current row. That means for row 2 there is only 1 object to be considered. And, for row 3, there are only objects 1, 2 and 3.
• Similarly, for columns, assume the knapsack only has the limit specified in the column. That means for the column, the knapsack can carry a maximum weight of 4 only.
• Use backtracking to find maximum possible value in the maximum limit of the knapsack.
• Consider the weight that has more value than the one with less value.
Step 2

The complete table:

Step 3

Starting with row 1, the knapsack can only have object 1 with weight 4 and value 5. Next, object 1 and 2 has a maximum weight of 7 and value 9. So, at the 7th column in the table the value will be 9. Moving on to the next row, the object 3 has a weight of 5 and value 7.

Now, by backtracking, in row 3 and column 7, the value of objects 1 and 2 combined (9) is greater than the value of object 3 (7). Hence, it will ...

Want to see the full answer?

See Solution

Want to see this answer and more?

Our solutions are written by experts, many with advanced degrees, and available 24/7

See Solution
Tagged in

Computer Science 