Professional Documents
Culture Documents
CSE225 Final Assignement
CSE225 Final Assignement
FINAL ASSIGNMENT
Department of Electrical & Computer Engineering
3. Graph (7)
Coin Change Problem: Suppose you have only 20, 10 and 5 taka
notes. Now you want give someone 45 taka. You can pay him in
several ways:
20, 20, 5 = 45
20, 10, 10, 5 = 45
10, 10, 10, 10, 5 = 45
20, 10, 5, 5, 5 = 45
…..
5, 5, 5, 5, 5, 5, 5, 5, 5 = 45
we want to find the minimum number of notes needed for this, in
this example it is 3 notes (20 + 20 + 5 these three notes make 45).
Here’s a explanation how this will work: the BFS algorithm starts
with root value 45, and it will have three adjacent vertices 25, 35
and 40. These nodes are found by subtracting the note values 20,
10 and 5 respectively. In the next step, the vertex 25 will have
three adjacent vertices: 5, 15, 20. They are also found by
subtracting the notes values respectively. You should continue
doing that until you reach the value 0.