Question: Given n items [I1,I2,,In], each with a size I. size (integer!) and a value I. value, and a total capacity c, find the most valuable
![Given n items [I1,I2,,In], each with a size I. size (integer!)](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f31e816ea5c_08866f31e80e61a5.jpg)
Given n items [I1,I2,,In], each with a size I. size (integer!) and a value I. value, and a total capacity c, find the most valuable way to pack items of total size at most c. Assume that we have following items: I1. size =3, and I1. value =5, I2. size =4, and I2. value =3, I3. size =2, and I3. value =4, I4. size =3, and I4. value =6. And your pack has capacity 7 . Fill in the following dynamic programming table for the problem: DP for Knapsack Just to remind you, the entry (i,j) should contain the optimal total value of the items packed in the bag, if we have items I1,I2,,Ii and the total capacity is j. That is for table entry at intersection of {I1,I2,I3} and 5 , we want to pack only subset of items {I1,I2,I3} and the total size of items packed should be 5 . The entry is then the optimal total value of items under these conditions
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
