in coin changing problem, show that the greedy strategy fails for the denominations 25, 20, 10, 5, and 1 cents. (hint: prove that we cannot construct the solution by making decisions to choose each item to add to the solution optimally, and never reversing decisions already made



Answer :

In coin changing problem,  the greedy strategy fails for the denominations 25, 20, 10, 5, and 1 cents.

The greedy algorithm for the coin change problem (pay a certain amount with the fewest number of coins feasible) is effective. It always chooses the coin with the largest denomination that does not exceed the remaining sum, and it consistently determines the right answer for certain coin sets.

But for certain set of denominations, it fails. For example take a sum of 44 cents then by greedy algorithm, first taking the highest denominations one 25 cent is taken and now 19 is remaining. So now one 10 cent is taken, and 9 is remaining. Now, one 5 cent is taken and four 1 cent is taken. So total we get 7 coins.

Now let us deviate from greedy algorithm and take two 20 cents, now 4 is remaining. So now four 1 cent is taken, this sums up only 6 coins. So this is a much optimal solution than the one obtained by greedy algorithm.

To know more on greedy algorithm

https://brainly.com/question/13197481

#SPJ4