Menu

[Solved]Knapsack Problem Thief Robbing Store Contains N Items 1 2 N Item Weight Wi 0 Value Vi 0 T Q37110639

Knapsack Problem

A thief is robbing a store which contains n items. For i = 1, 2,…, n, item i has weight wi > 0 and value vi > 0. The thiefcan carry a maximum weight of W pounds in a knapsack. The items canbe broken into smaller pieces, so the thief may decide to carryonly a fraction xi of object i, where 0 ≤ xi ≤ 1. Item icontributes xiwi to the total weight in the knapsack, and xivi tothe value of the load.

Design an algorithm to determine how much fraction of each itemthe thief should place into his knapsack so that the total value Pni=1 xivi is maximum. Of course the total weight of items he chooseswhich is equal to Pn i=1 xiwi shouldn’t exceed the capacity of theknapsack W. Also establish the order of growth for your algorithm’srunning time. For example, suppose the capacity of the knapsack is5 pounds and the store has four items A, B, C, D. The weight andvalue for each item are listed as follows:

item A B C D

weight (pounds) 2 3 2 4

value (dollars) 6 9 10 8

The thief can choose A and B, or A, C and 1/3 B which will havetotal values 15 dollars versus 19 dollars.

Expert Answer


Answer to Knapsack Problem A thief is robbing a store which contains n items. For i = 1, 2, …, n, item i has weight wi > 0 and v… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *