Question

please I would like assistance with this which are question 1 and 2, thank you

2. We have 5 objects, and the weights and values are No. 2 3 4 5 10 20 30 50 V 20 30 66 60 55 W 40 The knapsack can carry a w

Using Floyds algorithm (See Algorithm2 slide 54), calculate the length of the shortest path between each pair of nodes in th

10 B E 15 50 10 10 5 F 15 10 50 50 20 5 20 10 D

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution:

(2)

Given,

=>Number of objects = 5

No 1 2 3 4 5
w 10 20 30 40 50
v 20 30 66 60 55

=>Knapsack capacity = 90

(1)

Explanation:

=>Using greedy algorithm for 0-1 knapsack with highest value selection first.

=>Value order: 66 > 60 > 55 > 30 > 20

=>Highest value = 66 with weight = 30 is selected first and put it into the knapsack so capacity remaining = 60. Inserted object = 3

=>Now second heighest value = 60 with weight = 40 so put it into the knapsack so capacity remaining = 20. Inserted object = 4

=>Now value = 55 will be selected with weight 50 but as knapsack remaining capacity is 20( 50 > 20) so this weight is not possible to put into knapsack using 0-1 kanpsack(without breaking the weight).

=>Now value = 30 with weight = 20 will be selected so put it into knapsack so remaining capacity = 0 and we will stop here. Inserted object = 2

=>Hence subset of items = {2, 3, 4}

=>Total weight = 90

=>Total value = 66 + 60 + 30

=>Total value = 156

(2)

Explanation:

=>Using greedy algorithm for 0-1 knapsack by selecting lighest item first.

=>Order of weight: 10 < 20 < 30 < 40 < 50

=>Object 1 with weight 10 and value 20 will be selected first and put it into the knapsack so remaining capacity = 80

=>Object 2 with weight 20 and value 30 will be selected at second place so put it into the knapsack so remaining capacity = 60

=>Object 3 with weight 30 and value 66 will be selected now so put it into the knapsack so remaining capacity = 30

=>Now there is no way to select object 4 and object 5 because their weights are more tha remaining capacity.

=>Hence subset of items = {1, 2, 3}

=>Total weigth = 60

=>Total value = 20 + 30 + 66

=>Total value = 116

(3)

Explanation:

=>Using greedy algorithm for 0-1 knapsack by selecting highest density first.

Finding density(v/w):

No 1 2 3 4 5
w 10 20 30 40 50
v 20 30 66 60 55
v/w 2 1.5 2.2 1.5 1.1

=>Order of density: object 3 > object 1 > object 2 = object 4 > object 5

=>Select object 3 with weight 30 and value 66 so put it into knapsack so remaining capacity = 60

=>Select object 1 with weight 10 and value 20 so put it into knapsack so remaining capacity = 50

=>As objects 2 and 4 have equal density so go for higher profit means select object 4 with weight 40 and value 60 so put it into knapsack and remaining capacity = 10

=>There is no way to select object 2 and object 5 because their capacities are more than remaining capacities.

=>Subset of items = {1, 3, 4}

=>Weight = 80

=>Value = 66 + 20 + 60

=>Value = 146

(4)

Explanation:

=>Using greedy algorithm for fractional knapsack by selecting highest density first.

Finding density(v/w):

No 1 2 3 4 5
w 10 20 30 40 50
v 20 30 66 60 55
v/w 2 1.5 2.2 1.5 1.1

=>Order of density: object 3 > object 1 > object 2 = object 4 > object 5

=>Select object 3 with weight 30 and value 66 so put it into knapsack so remaining capacity = 60

=>Select object 1 with weight 10 and value 20 so put it into knapsack so remaining capacity = 50

=>As objects 2 and 4 have equal density so go for higher profit means select object 4 with weight 40 and value 60 so put it into knapsack and remaining capacity = 10

=> Now select object 2 with weight 20 and value 30, break it into 2 parts so value associated with each part is 15 and put one part of weight 10 into knapsack so remaining capacity = 0

=>Subset of items = {1, 2, 3, 4}

=>Weight = 90

=>Value = 66 + 20 + 60 + 15

=>Value = 161

I have explained each and every part of the first question only according to "HOMEWORKLIB RULES when multiple questions are given then only first question needs to be answered" with the help of statements attached to it.

Add a comment
Know the answer?
Add Answer to:
please I would like assistance with this which are question 1 and 2, thank you 2....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • For given capacity of knapsack W and n items {i1,i2,...,in} with its own value {v1,v2,...,vn} and...

    For given capacity of knapsack W and n items {i1,i2,...,in} with its own value {v1,v2,...,vn} and weight {w1,w2,...,wn}, find a greedy algorithm that solves fractional knapsack problem, and prove its correctness. And, if you naively use the greedy algorithm to solve 0-1 knapsack problem with no repetition, then the greedy algorithm does not ensure an optimal solution anymore. Give an example that a solution from the greedy algorithm is not an optimal solution for 0-1 knapsack problem.

  • There is no known Greedy strategy that is optimal for solving the 0/1 Knapsack problem. For...

    There is no known Greedy strategy that is optimal for solving the 0/1 Knapsack problem. For each of the following strategies give a counterexample, i.e. descibe an instance where that strategy will fail to produce an optimal result. (a) Lightest item first. (b)Most valuable item first. (c)Item with the best value to weight ratio first.

  • 1. Fractional Knapsack Problem Algorithm Which best describes the tightest range of the number of items...

    1. Fractional Knapsack Problem Algorithm Which best describes the tightest range of the number of items with only fractional inclusion (i.e. not entirely included or excluded) in the knapsack? (Let n denote the number of items for possible inclusion.) A) At least 0 items and at most n items B) At least 1 items and at most n items C) Exactly n items D) At least 0 items and at most n-1 items E) At least 1 items and at...

  • Recall that in the "Knapsack Problem", there are n items having respective values V1..n) and weights...

    Recall that in the "Knapsack Problem", there are n items having respective values V1..n) and weights W1..n), all greater than 0 and one needs to maximize the total value of the subset of the items placed in the knapsack limited by a weight capacity of W In the 0-1 Knapsack Problem, each item must be either be included or excluded in its entirety, in light of the fact that this problem is to be "NP-Complete", how can one solve the...

  • There are n items in a store. For each item i=1,2,...,n the weight of the item...

    There are n items in a store. For each item i=1,2,...,n the weight of the item is wi and the value of the item is vi. A thief is carrying a knapsack of weight W. In this version of a problem the items can be broken into smaller pieces, so the thief may decide to carry only a fraction xi of object i, where 0≤xi ≤1. Item i contributes xiwi to the total weight in the knapsack, and xivi to...

  • 1. Apply the dynamic programming algorithm discussed in class to solve the knapsack problem. (10 points)...

    1. Apply the dynamic programming algorithm discussed in class to solve the knapsack problem. (10 points) a. Show the completed table. b. Which items are included in the final configuration of the knapsack? c. What is the maximum value that can fit in the knapsack using a configuration of these items? item 1 2. 3 4 weight 3 2 value $25 $20 $15 1 capacity W = 6. 4 5 $40 $50 5

  • 5) (10 pts) Greedy Algorithms The 0-1 Knapsack problem is as follows: you are given a...

    5) (10 pts) Greedy Algorithms The 0-1 Knapsack problem is as follows: you are given a list of items, each item has an integer weight and integer value. The goal of the problem is to choose a subset of the items which have a sum of weights less than or equal to a given W with a maximal sum of values. For example, if we had the following five items (each in the form (weight, value)): 11(6, 13), 2(4, 10),...

  • solution is required in pseudo code please. 2 Knapsack Problem În al Knapsack problem. given n items(11-12. . . ....

    solution is required in pseudo code please. 2 Knapsack Problem În al Knapsack problem. given n items(11-12. . . . . 1"} with weight {w1·W2. . . . . ux) and value (n 2, .., nJ, the goal is to select a combination of items such that the total value V is maximized and the total weight is less or equal to a given capacity In this question, we will consider two different ways to represent a solution to the...

  • 2 Knapsack Problem In a Knapsack problem, given n items {11, I2, -.., In} with weight {wi, w2, -.., wn) and value fvi,...

    2 Knapsack Problem In a Knapsack problem, given n items {11, I2, -.., In} with weight {wi, w2, -.., wn) and value fvi, v2, ..., vn], the goal is to select a combination of items such that the total value V is maximized and the total weight is less or equal to a given capacity W. Tt i=1 In this question, we will consider two different ways to represent a solution to the Knapsack problem using an array with size...

  • For the following questions, use the graph (starting node: S) below: 14. Show DFS traversal. 15....

    For the following questions, use the graph (starting node: S) below: 14. Show DFS traversal. 15. Show BFS traversal. 16. Show the result of a topological sorting of the graph 17. Dijikstra's single source shortest paths for all nodes 18. Show a tabular form soultion of following 0/1 knapsack problem. Value {5,7, 3, 10, 12, 4, 10} Weight {2,3,1,5, 6, 2,4} Total Weight: 12 19. Show a solution to Fractional knapsack problem with the same weight, value, and total weight...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT