Coins

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 6

1

FIND MINIMUM NUMBER OF COINS

REPRESENTED BY:
Name : Malaviya Rajan A.
Enrollment no : 21002170210046
Roll no. : 202
Branch : IT
Division : S7
2

ABOUT THE GREEDY ALGORITHM

🔶 In Greedy algorithm the decision of solution it’s taken based on the information
available.
🔶 It works in a top-down approach.
🔶 A greedy algorithm is an approach for solving a problem by selecting the best option
available at the moment.
🔶 This method use for solving optimization problem.
🔶 In greedy method there is no as such guarantee of getting optimal solution.
ABOUT THE PROJECT
🔶At first , we’ll know the change making problem with a real-life example.

🔶 Given a value of V Rs and an infinite supply of each of the denominations {1, 2, 5, 10,
20, 50, 100, 500, 1000} valued coins/notes, The task is to find the minimum number of
coins and/or notes needed to make the change.

🔶 The intuition would be to take coins with greater value first. This can reduce the total
number of coins needed. Start from the largest possible denomination and keep adding
denominations while the remaining value is greater than 0.

3
ALGORITHM

STEP-1 : Sort the array of coins in decreasing order.


STEP-2 : Initialize result as empty.
STEP -3 : Find the largest denomination that is smaller than current amount.
STEP-4: Add found denomination to result. Subtract value of found denomination from
amount.
STEP-5: If amount becomes 0, then print result.
STEP-6: Else repeat steps 3 and 4 for new value of V.

4
DISADVANTAGES
🔶 The greedy algorithm doesn't always guarantee the optimal solution however
it generally produces a solution that is very close in value to the optimal

🔶 The algorithm never reverses the earlier decision even if the choice is wrong.

5
6

Thank you!

You might also like