Week 5 Discussion Forum

Coin change problem

Coin change problem

by Md. Mazbaur Rashid (MMR) -
Number of replies: 0

What is Coin change problem? It is the topic where after marketing if we give a shopkeeper a bigger note, after taking the price of all things we bought, if extra money is available then he will give some changes to us.

In an example, suppose if you buy something which price is 450 taka and give a 500 taka note to the seller, as a change he must return 50 takas.

Now greedy algorithm’s coin change method allows us to arrange the notes/coins whatever we say in a way that the seller can easily find a solution to return changes.

Suppose he has 4 notes where 2 is of 20 takas, 1 is of 10 takas and the other is of 5 takas and he will have to return 50 takas in total. Greedy algorithm will help him to find which notes he will have to return.

In this case greedy algorithm will start count from the largest note and one after another in descending order and will return an output of 20, 20, 10. Which means he will have to return 2 20 takas note and a 10 takas note. That’s how it works basically.

 

198 words