https://github.com/ayvero/java_greedy_coin-change
Given a set **C** of **N** coin types, with an unlimited supply of each, the goal is to determine the minimum number of coins needed to obtain a total amount **M**.
https://github.com/ayvero/java_greedy_coin-change
greedy-algorithms java
Last synced: 6 months ago
JSON representation
Given a set **C** of **N** coin types, with an unlimited supply of each, the goal is to determine the minimum number of coins needed to obtain a total amount **M**.
- Host: GitHub
- URL: https://github.com/ayvero/java_greedy_coin-change
- Owner: Ayvero
- Created: 2025-03-26T21:44:48.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-03-26T21:48:40.000Z (6 months ago)
- Last Synced: 2025-03-26T22:31:42.532Z (6 months ago)
- Topics: greedy-algorithms, java
- Language: Java
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Problema del Cambio de Monedas
## Descripción del Problema
Dado un conjunto **C** de **N** tipos de monedas con un número ilimitado de cada una, el objetivo es determinar el mínimo número de monedas necesarias para formar una cantidad **M**.Por ejemplo, si un cajero automático tiene billetes de valores: **100$, 25$, 10$, 5$ y 1$**, y se necesita pagar **289$**, la mejor solución consiste en dar **10 billetes**:
- **2 de 100$**
- **3 de 25$**
- **1 de 10$**
- **4 de 1$**## Enfoque
- **Algoritmo voraz (Greedy)**: Si las denominaciones lo permiten, se usa un enfoque voraz para seleccionar la moneda más grande posible primero.
- **Programación dinámica**: Si el enfoque voraz no es óptimo, se implementa programación dinámica para garantizar el número mínimo de monedas.
- **Casos límite**: Se consideran situaciones en las que no es posible formar la cantidad **M** exacta.## Aplicaciones
Este problema es útil en diversas áreas:
- **Sistemas financieros y de pago**: Cajeros automáticos, máquinas expendedoras y transacciones en línea.
- **Algoritmos de optimización**: Asignación eficiente de recursos y problemas de minimización.
- **Teoría de la computación**: Análisis de eficiencia de algoritmos y complejidad computacional.- -------------------------------------------------------------------------------------
# Coin Change Problem
## Problem Description
Given a set **C** of **N** coin types, with an unlimited supply of each, the goal is to determine the minimum number of coins needed to obtain a total amount **M**.For example, if a cash machine has bills of values: **100$, 25$, 10$, 5$, and 1$**, and we need to pay **289$**, the optimal solution is to give **10 bills**:
- **2 of 100$**
- **3 of 25$**
- **1 of 10$**
- **4 of 1$**## Approach
- **Greedy Algorithm**: If the coin denominations allow it, use a greedy approach to take the largest possible coin first.
- **Dynamic Programming**: If the greedy approach is not optimal, use dynamic programming to ensure the minimal number of coins is selected.
- **Edge Cases**: Consider cases where it's impossible to make the exact amount **M**.## Applications
This problem is widely used in:
- **Finance & Payment Systems**: ATM cash withdrawals, vending machines, and online transactions.
- **Optimization Algorithms**: Resource allocation and minimization problems.
- **Theoretical Computer Science**: Algorithm efficiency and computational complexity analysis.