2 10 points Show that if there were a coin worth 9 cents the

2. (10 points) Show that if there were a coin worth 9 cents, the greedy algorithm using quarters, dimes, 9-cent coins, nickels, and pennies would not always produce change using the fewest coins possible. Note: for full credit, you need to find an example where the greedy algorithm does not produce change using the fewest coins possible, and then describe why this example works: trace the greedy algorithm to explain how many coins it would produce in change? what’s a better way to make change using fewer coins? Second note: for worked examples related to this question, refer to Week 1 discussion section worksheet

Solution

The algorithm can use maximum number of quarters, three, leaving 9 cents coins. It can use maximum number of dimes, one penny.Greedy algorithm will work.

The greedy algorithm is having one quarter, leaving 9 cents coin , then 8pennies total of 9 coins.

Thus gredy algorithm is not correct for this coins.

Thank you.

2. (10 points) Show that if there were a coin worth 9 cents, the greedy algorithm using quarters, dimes, 9-cent coins, nickels, and pennies would not always pro

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site