Question

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), I3(1, 1), 14(8, 12), and 15(5, 9) and W 13, then our maximal achievable value is 13 + 10 + 1 = 24. corresponding to the subset containing the first three items, which weigh 11 units, which is less than or equal to our weight limit of 13 units. A proposed greedy algorithm to solve the problem is as follows: (1) sort the items by per unit value. Go through the list of items in this order, taking each item as long as there is room to do so. (For this example, when we sort by per unit value, the ordering would be 12, 11, 15, 14, and 13. Then, wed take 12, followed by 11. Skip 15 and 14 because enough weight wasnt left, then take I3.) This algorithm is incorrect. Create a single example (a set of items with weights and values) for which this algorithm fails. In your example, show what answer the algorithm will produce and show a subset that is more valuable (but also within the weight limit.)

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

Consider I1(6,13), I2(4,10), I3(3,15), I4(2,10), I5(1,10)
and W = 13
Sorting the items by per unit value i.e., value / weight
I5,I3,I4,I2,I1
Consider subset (I5,I3,I4,I2)
weight: 1 + 3 + 2 + 4 = 10
values: 10 + 15 + 10 + 10 = 45
But in this case if we consider the subset (I5,I3,I4,I1)
weight: 1 + 3 + 2 + 6 = 12
values: 10 + 15 + 10 + 13 = 48
We can get more value with in the given weight. If we consider the other subset.
Hence the algorithm is wrong.

Add a comment
Know the answer?
Add Answer to:
5) (10 pts) Greedy Algorithms The 0-1 Knapsack problem is as follows: you are given a...
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
  • "Greedy, but Better": Given a knapsack problem with a weight capacity C, and n items, and...

    "Greedy, but Better": Given a knapsack problem with a weight capacity C, and n items, and each item has a weight W[1:n] and monetary value P[1:n]. You have to determine which items to take so that the total weight is C, and the total value (profit) is maximized. In this case we are considering an integer problem, so you can either take an item, or not take an item, you cannot take it fractionally. If you recall, the greedy algorithm...

  • 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...

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

    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 weight not exceeding 90, find a subset items and give the total weight and value for following algorithms: 1) By using the algorithm of greedy of value for 0-1 knapsack problem? By...

  • Consider the following greedy algorithm for the knapsack problem: each time we pick the item with...

    Consider the following greedy algorithm for the knapsack problem: each time we pick the item with the highest value to weight ratio to the bag. Skip items that will make the total weight exceeded the capacity of the bag. Find a counterexample to show that this approach will not work, and the result could be 100 times worse than the optimal solution. That is, construct a table of set of items with weight and values and find a bag capacity...

  • 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...

  • 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...

  • 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.

  • 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...

  • The decision version of the Knapsack problem is as follows: Given a set of n items...

    The decision version of the Knapsack problem is as follows: Given a set of n items {1, 2, …, n}, where each item j has a value v(j) and a weight w(j), and two numbers V and W, can we find a subset X of {1, 2, …, n} such that Σj∈X v(j) ≥ V and Σj∈X w(j) ≤ W? Prove formally that the Knapsack problem is NP-complete.

  • 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

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