How would you apply the Greedy technique in this situation/why wouldn't it work?

65 Views Asked by At

I am going over the Rod Cutting Problem

The author states "Selling a rod of length $i$ units earns $P$[i] dollars."

Here is the table $P$ for this problem

enter image description here

I'am currently going over this question in the worksheet : "Try greedy techniques. Convince yourselves they do not quite work"

How would you use the greedy technique here? I saw that a Greedy Algorithm is an algorithm that decides the next step on if it "will provide the most obvious benefit.", not the bigger picture.

How would you apply that definition here? I am confused because that definition could be subjective - I could think that selling it as a whole would provide the most obvious benefit while Jim could think that cutting it into nine pieces would provide the most benefit.

Based on my perspective, the greedy algorithmm would work.

1

There are 1 best solutions below

0
On

You may be right when you say that it is not clear what provides "the most obvious benefit", but I think the following is what they mean.

You get the best price per unit length by cutting off a rod of length $6$, so we do this first, leaving a rod of length $3$. From this remaining rod, the best price per unit length is for a rod of length $2$, so we do this next, leaving length $1$ for the third and last piece. This gives a division into three pieces, $6+2+1$, and a total income of $16+5+1=22$.

But this is not the best possible income since we can see by trial and error that, for example, cutting the rod into lengths $7+2$ gives a total income of $18+5=23$. (I'm not sure whether this gives the best possible income. Maybe, maybe not - which is exactly why we would like to have an algorithm rather than just trial and error.)

Alternatively, if you interpret the greedy algorithm as finding the best immediate price (not price per unit length), you would sell the rod as a whole (as you suggested) giving income $22$, which is still not as good as $23$.

I'm afraid I do not understand the rationale for cutting into nine pieces (maximum number of pieces maybe?), but this gives income of only $9$, which is far worse than $23$.