Question: I need.a nested list and output items and total values. Seen this on here before put not sure it answers my questions correctly. Thanks 3.

I need.a nested list and output items and total values. Seen this on here before put not sure it answers my questions correctly. ThanksI need.a nested list and output items and total values. Seen this

3. Knapsack problem The following table is a set of items sorted by their value per unit of weight. You need to decide how many items you can carry in your luggage. Start by placing items with the highest value per unit of weight. If placing a new item causes the final weight to exceed the limit Wmax, you should skip this item and try the next item. For example, if Wmax = 10, you can only carry item A, B, D and J. The total weight is 5 +3+1+1 = 10 and the total value is 5 x 310 + 3 x 270 + 1 x 150 + 1 x 30 = 2540. You cannot carry A, B and C, because the total weight 5+ 3+ 4.5 = 12.5 exceeds the limit. Hint: Check items according to this order: A+B+C+D+E+FG>H>I>J. Item name (mk) Weight (wk) Value per unit of weight (VK) A 5 310 B 3 270 4.5 220 D 1 150 E 3.5 140 F 2.5 90 G 4 70 H 3 60 I 2 50 J 1 30 (a) Create a nested list based on the above table: [[ma, W, VA], [MB, WB, VB], ..., , [mj, wj,y;]]. The first element mk in the sublist is item name, the second element wk is the weight of the item, and the third element vk is the value of item per weight. (b) Given the limit Wmax = 23, print out the name of items you decided to carry in your luggage and their total value. 3. Knapsack problem The following table is a set of items sorted by their value per unit of weight. You need to decide how many items you can carry in your luggage. Start by placing items with the highest value per unit of weight. If placing a new item causes the final weight to exceed the limit Wmax, you should skip this item and try the next item. For example, if Wmax = 10, you can only carry item A, B, D and J. The total weight is 5 +3+1+1 = 10 and the total value is 5 x 310 + 3 x 270 + 1 x 150 + 1 x 30 = 2540. You cannot carry A, B and C, because the total weight 5+ 3+ 4.5 = 12.5 exceeds the limit. Hint: Check items according to this order: A+B+C+D+E+FG>H>I>J. Item name (mk) Weight (wk) Value per unit of weight (VK) A 5 310 B 3 270 4.5 220 D 1 150 E 3.5 140 F 2.5 90 G 4 70 H 3 60 I 2 50 J 1 30 (a) Create a nested list based on the above table: [[ma, W, VA], [MB, WB, VB], ..., , [mj, wj,y;]]. The first element mk in the sublist is item name, the second element wk is the weight of the item, and the third element vk is the value of item per weight. (b) Given the limit Wmax = 23, print out the name of items you decided to carry in your luggage and their total value

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!