Question

In: Computer Science

KNAPSACK Optimization Problem using Greedy Method Problem 1: Item Weight Value 1 14 20 2 6...

KNAPSACK Optimization Problem using Greedy Method
Problem 1:
Item Weight Value
1 14 20
2 6 16
3 10 8
4 5 10
5 4 12
Allowed weight = 24 Kg

Problem 2:
Item Weight Value
1 6 30
2 8 40
3 15 45
4 22 88
5 25 80
Allowed weight = 60 Kg

Problem 3:
Item Weight Value
1 6 30
2 8 40
3 15 45
4 22 88
5 25 80
Allowed weight = 60 Kg



Solutions

Expert Solution

by using fractional method to solve the knapsack problrm using greedy approach:

Problem 1:
Item Weight Value Value /weight
1 14 20 20/14
2 6 16 16/6
3 10 8 8/10
4 5 10 10/5
5 4 12 12/4
Allowed weight = 24 Kg

greedy to weight ,

W=24-4=20,V5=12

W=20-5=15,V4=10

W=15-6=9,V2=16

W=9-9=0

V3=(9/10)*8=7.2

Value=12+10+16+7.2=45.2

items chosen=(0,1,9/10,1,1)

greedy to value,

Item Weight Value Value /weight
1 14 20 20/14
2 6 16 16/6
3 10 8 8/10
4 5 10 10/5
5 4 12 12/4
Allowed weight = 24 Kg

W=24-14=10,V1=20

W=10-6=4,V2=16

W=4-4=0,V5=12

Value=20+16+12=48

items chosen=(1,1,0,0,1)

greedy to value/weight

Item Weight Value Value /weight
1 14 20 20/14=1.42
2 6 16 16/6=2.66
3 10 8 8/10=0.8
4 5 10 10/5=2
5 4 12 12/4=3

Allowed weight = 24 Kg

W=24-4=20,V5=12

W=20-6=14,V2=16

W=14-5=9,V4=10

W=9-9=0,V1=(9/14)*20=12.8

Value=12+16+10+12.85=50.8

items chosen=(9/14,1,0,1,1)

Problem 2:
Item Weight Value
1 6 30
2 8 40
3 15 45
4 22 88
5 25 80
Allowed weight = 60 Kg

greedy to weight ,

w=60-6=54,V1=30

w=54-8=46,V2=40

w=46-15=31,V3=45

w=31-22=9,V4=88

w=9-9=0,V5=9/25*80=28.8

Value=30+40+45+88+28.8=231.8

items chosen=(1,1,1,1,9/25)

greedy to value,

Item Weight Value
1 6 30
2 8 40
3 15 45
4 22 88
5 25 80
Allowed weight = 60 Kg

W=60-22=38,V4=88

W=38-25=13,V5=80

W=13-13=0,V3=13/15*45=39

Value=88+80+39=207

items chosen=(0,0,13/15,1,1)

greedy to value/weight,

Item Weight Value Value/Weight
1 6 30 30/6=5
2 8 40 40/8=5
3 15 45 45/15=3
4 22 88 88/22=4
5 25 80 80/25=3.2
Allowed weight = 60 Kg

W=60-6=54,V1=30

W=54-8=46,V2=40

W=46-22=24,V4=88

W=24-24=0,V5=24/25*80=76.8

Value=30+40+88+76.8=234.8

items chosen=(1,1,0,1,24/25)


Related Solutions

Consider the following items in the Knapsack Problem: Item                weight             value &nbsp
Consider the following items in the Knapsack Problem: Item                weight             value            Knapsack capacity W = 9. 1                      3                   $6 2 4 $12 3                      2                  $10 4                      5                  $20 Determine the maximum value in the knapsack if we allow repetitions; i.e., if there are an unlimited number of each item so that more than one such item can be chosen. Find the missing value in the following linear array. P(w) is the maximum profit obtainable for a knapsack of capacity w. w-->             0       1      2       3       4       5       6       7       8       9 P(w):    0 0 10 10     20     20     30    30 40 ?   P(9)...
In C++ or Java Write the Greedy programming Algorithm for the 0-1 Knapsack problem.                    (a)...
In C++ or Java Write the Greedy programming Algorithm for the 0-1 Knapsack problem.                    (a) No fraction allowed Max Weight W= 9 item 1: profit $20, weight 2, prof/weight=$10 item 2: profit $30, weight 5, prof/weight=$6 item 3: profit $35, weight 7, prof/weight=$5 item 4: profit $12, weight 3, prof/weight=$4 item 5: profit $3, weight 1, prof/weight=$3
Week 1 2 3 4 5 6 Value 18 14 15 10 17 15 Using the...
Week 1 2 3 4 5 6 Value 18 14 15 10 17 15 Using the naïve method (most recent value) as the forecast for the next week, compute the following measures of forecast accuracy. (a) Mean absolute error If required, round your answer to one decimal place. (b) Mean squared error If required, round your answer to one decimal place. (c) Mean absolute percentage error If required, round your intermediate calculations and final answer to two decimal places. (d)...
Solve the initial value problem below using the method of Laplace transforms. ty''-4ty'+4y=20, y(0)=5 y'(0)=-6
Solve the initial value problem below using the method of Laplace transforms. ty''-4ty'+4y=20, y(0)=5 y'(0)=-6
Solve the initial value problem once using power series method and once using the characteristic method....
Solve the initial value problem once using power series method and once using the characteristic method. Please show step for both 3) 3y”−y=0, y(0)=0,y’(0)=1 Note that 3y” refers to it being second order differential and y’ first
Using newton's method, estimate the value of 5^1/7 accurately to 6 decimal places.
Using newton's method, estimate the value of 5^1/7 accurately to 6 decimal places.
Build a Max Heap using the following: A= {20, 15, 10, 14, 8, 6, 9}
Build a Max Heap using the following: A= {20, 15, 10, 14, 8, 6, 9}
Given the following data       Output        Total cost output total cost 0 6 1 14 2 20...
Given the following data       Output        Total cost output total cost 0 6 1 14 2 20 3 24 4 32 5 45 6 60 What is the value of total fixed cost? _______ What is the value of total variable cost when output= 4? _______ What is the value of average total cost when output equals 6?______ What is the marginal cost of the fifth unit?_______ AT what level of output is marginal cost at its minimum value? _____
Solve the initial value problem below using the method of Laplace transforms. y"-4y'+13y=10e^3t y(0)=1, y'(0)=6
Solve the initial value problem below using the method of Laplace transforms. y"-4y'+13y=10e^3t y(0)=1, y'(0)=6
Problem 14-22 Determine bond price; record interest; report bonds at fair value [LO14-6] On January 1,...
Problem 14-22 Determine bond price; record interest; report bonds at fair value [LO14-6] On January 1, 2018, NFB Visual Aids issued $900,000 of its 20-year, 6% bonds. The bonds were priced to yield 8%. Interest is payable semiannually on June 30 and December 31. NFB Visual Aids records interest expense at the effective rate and elected the option to report these bonds at their fair value. On December 31, 2018, the fair value of the bonds was $730,000 as determined...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT