Question: Consider the coin change problem we discussed in class: Consider a currency system with coins worth a1, a2, , ak cents where a1 = 1.
Consider the coin change problem we discussed in class: Consider a currency system with coins worth a1, a2, , ak cents where a1 = 1. Assume that you are given an unlimited numbers of coins of each type. The input to the problem is an integer M and the objective is to determine the number of coins of each type to make up M cents using the minimum number of coins. Consider a greedy algorithm that takes as many coins as possible from the highest denomination, and repeat this with the next highest one, etc.
Prove that this greedy algorithm correctly solve the coin change problem for the case when a1 = 1, a2 = 5, a3 = 10, a4 = 25, and a5 = 50.
I think any language is fine but I dont think you need a language. Its more algorithm based and need to prove using algorithm
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
