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
You are an algorithm designer and you came up with four different divide-and-conquer algorithms for some...
You are an algorithm designer and you came up with four different divide-and-conquer algorithms for some problem Q. Those four algorithms are described below in parts (1), (2), (3), and (4). You wrote those descriptions a long time ago so now you want to remind yourself, for each one of them, what was the corresponding recurrence relation and provide an upper bound on the running time. So first give the recurrence then solve it using any method of your choice...
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...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT