Discrete Mathematics and Its Applications, Seventh Edition

Published by McGraw-Hill Education
ISBN 10: 0073383090
ISBN 13: 978-0-07338-309-5

Chapter 3 - Section 3.1 - Algorithms - Exercises - Page 204: 56

Answer

Greedy Algorithm returns one 12 cents coin and three pennies for a total of 15 cents which uses 4 coins. However, this is not the best possible as it is possible to form 15 cents with only two coins one dime and one nicker.

Work Step by Step

Let us consider the amount of 15 cents $$n=15$$ $First$ $pass$ $(Quarters)$ $c_{1}=25 $ we note that $n<25$ , thus the first pass ends. $Second$ $pass$ $(12$ $cent$ $coins)$ $c_{2}=12$ we note that $n\geq12$ this we add 1 12-cent coin and decrease the total amount by 12. $$ d_{2} = 1$$ $$ n=n_{old} - 12 = 15 - 12=3$$ We note that $c<12$ thus the second pass ends. $Third$ $pass$ $(Dimes)$ $c_{3}=10 $ we note that $n<10$ thus the third pass ends here. $Fourth$ $pass$ $(Nickels)$ $c_{4}=5$ we note that $n<5$ hence the Fourth pass ends. $Fifth$ $pass$ $(pennies)$ $c_{5}=1 $ here we can see that $n\geq 1$ hence we add 1 penny and decrease the total amount by 1. $$d_{2}=1$$ $$d_{5}=1$$ $$n=n_{old}-1=3-1=2$$ here we can see that $n\geq 1$ hence we add 1 penny and decrease the total amount by 1. $$d_{2}=1$$ $$d_{5}=1$$ $$n=n_{old}-1=2-1=1$$ here we can see that $n\geq 1$ hence we add 1 penny and decrease the total amount by 1. $$d_{2}=1$$ $$d_{5}=1$$ $$n=n_{old}-1=1-1=0$$ Hence here you can see that $n<1$ so the fifth pass ends here. Using the above-given values we can say the $conclusion$ is : 15 cents can be obtained by using one 12 cents coin and three pennies, which then use 4 coins in total. However, this is not the best possible as it is possible to form 15 cents with only two coins one dime and one nicker.
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.