Question

1 (a): Give an example that shows the greedy algorithm that picks the item with largest...

1 (a): Give an example that shows the greedy algorithm that picks the item with largest profit first (and continues in that fashion) does not solve the 0 − 1 Knapsack problem.

1 (b): Give an example that shows the greedy algorithms that picks the object with largest profit first (and continues in that fashion) does not solve the Fractional Knapsack problem.

Please show your work! I will rate quality answers. Thank you!

Homework Answers

Answer #1

Two main kinds of Knapsack Problems:
1.0-1 Knapsack

* N items (can be the same or different)

* Have only one of each

*Must leave or take (ie 0-1) each item (eg ingots of gold)

*DP (Dynamic programming )works, greedy does not

2.Fractional Knapsack

*N items (can be the same or different)

*Can take fractional part of each item (eg bags of gold dust)

*Greedy works and DP algorithms work

1 a). Greedy doesn't work for 0-1 Knapsack Problem:

Example 1: Knapsack Capacity W = 25 and
Item   A   B   C   D
Price   12   9   9   5
Size   24   10   10   7

Optimal: B and C. Size=10+10=20. Price=9+9=18
Possible greedy approach: take largest Price first (Price=12, not optimal)
Possible greedy approach: take smallest size item first (Price=9+5=14, not optimal)

1b) greedy algorithms that picks the object with largest profit first (and continues in that fashion) does solve the Fractional Knapsack problem.

Item   A   B   C   D
Value   50   140   60   60
Size   5   20   10   12
Ratio   10   7   6   5

Solution:
All of A, all of B, and ((30-25)/10) of C (and none of D)
Size: 5 + 20 + 10*(5/10) = 30
Value: 50 + 140 + 60*(5/10) = 190 + 30 = 220

Time: Θ(n), if already sorted

Know the answer?
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
Similar Questions
Question 1: The data table shows the sugar content of a fruit (Sugar) for different numbers...
Question 1: The data table shows the sugar content of a fruit (Sugar) for different numbers of days after picking (Days). Days Sugar 0 7.9 1 12.0 3 9.5 4 11.3 5 11.8 6 10.3 7 4.2 8 0.8 HAND CALCULATIONS: The dependent (Y) variable is sugar content and the independent (X) variable is number of days after picking (Days). Do the following by hand, SHOWING WORK. You may use SAS/R to check your answers if you want. (a) Find...
MATH125: Unit 1 Individual Project Answer Form Mathematical Modeling and Problem Solving ALL questions below regarding...
MATH125: Unit 1 Individual Project Answer Form Mathematical Modeling and Problem Solving ALL questions below regarding SENDING A PACKAGE and PAINTING A BEDROOM must be answered. Show ALL step-by-step calculations, round all of your final answers correctly, and include the units of measurement. Submit this modified Answer Form in the Unit 1 IP Submissions area. All commonly used formulas for geometric objects are really mathematical models of the characteristics of physical objects. For example, a basketball, because it is a...
Item 1 In the case below, the original source material is given along with a sample...
Item 1 In the case below, the original source material is given along with a sample of student work. Determine the type of plagiarism by clicking the appropriate radio button. Original Source Material Student Version When instructors are creating discussion board activities for online courses, at least two questions must be answered. First, what is the objective of the discussions? Different objectives might be to create a "social presence" among students so that they do not feel isolated, to ask...
Item 1 In the case below, the original source material is given along with a sample...
Item 1 In the case below, the original source material is given along with a sample of student work. Determine the type of plagiarism by clicking the appropriate radio button. Original Source Material Student Version There is a desperate need for theorists and researchers to generate and refine a new breed of learning-focused instructional design theoriesthat help educators and trainers to meet those needs, (i.e., that focus on learning and that foster development of initiative, teamwork, thinking skills, and diversity)....
Item 1 In the case below, the original source material is given along with a sample...
Item 1 In the case below, the original source material is given along with a sample of student work. Determine the type of plagiarism by clicking the appropriate radio button. Original Source Material Student Version Major changes within organizations are usually initiated by those who are in power. Such decision-makers sponsor the change and then appoint someone else - perhaps the director of training - to be responsible for implementing and managing change. Whether the appointed change agent is in...
Item 1 In the case below, the original source material is given along with a sample...
Item 1 In the case below, the original source material is given along with a sample of student work. Determine the type of plagiarism by clicking the appropriate radio button. Original Source Material Student Version But what are reasonable outcomes of the influence of global processes on education?While the question of how global processes influence all aspects of education (and who controls these forces) is multidimensional and not completely testable, there appear to be some theories of globalization as it...
Item 1 In the case below, the original source material is given along with a sample...
Item 1 In the case below, the original source material is given along with a sample of student work. Determine the type of plagiarism by clicking the appropriate radio button. Original Source Material Student Version A communication channel is the means by which messages get from one individual to another. The nature of the information-exchange relationship between a pair of individuals determines the conditions under which a source will or will not transmit the innovation to the receiver and the...
ch 6 1: It is generally a good idea to gain an understanding of the "size"...
ch 6 1: It is generally a good idea to gain an understanding of the "size" of units. Consider the objects and calculate the kinetic energy of each one. A ladybug weighing 37.3 mg flies by your head at 3.83 km/h . ×10 J A 7.15 kg bowling ball slides (not rolls) down an alley at 17.5 km/h . J A car weighing 1260 kg moves at a speed of 49.5 km/h. 5: The graph shows the ?-directed force ??...
1) Describe an example of each of the following that may be found of your kitchen:...
1) Describe an example of each of the following that may be found of your kitchen: Explain how your choice falls into this category, and if there is a chemical name or symbol for it, provide that as well. Provide a photo of your example with your ID card in it. a) a compound b) a heterogeneous mixture c) an element (symbol) Moving to the Caves… Lechuguilla Caves specifically. Check out this picture of crystals of gypsum left behind in...
exhibit one 2006 2005 2004 2003 2002 sales 78,599,808 81,874,800 86,184,000 75,600,000 67,500,000 sales in units...
exhibit one 2006 2005 2004 2003 2002 sales 78,599,808 81,874,800 86,184,000 75,600,000 67,500,000 sales in units 5,239,987 5,458,320 5,745,600 5,040,000 4,500,000 cost of goods sold variable variable 29,081,929 31,112,424 31,026,240 27,972,000 24,975,000 fixed $27,865,240 23,221,033 21,701,900 19,729,000 18,100,000 gross profit $21,652,639 27,541,343 33,455,860 27,899,000 24,425,000 atributable costs marketing $5,894,986 6,140,610 5,774,328 5,140,800 4,758,750 other (primarily fixed) $2,517,537 2,502,522 2,317,150 2,106,500 1,915,000 product line profit before G&A allocation $13,240,117 18,898,211 25,364,382 20,651,700 17,751,250 return on sales 16.84% 23.08 29.43 27..32 26.30...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT