Questions tagged [coin-change]
29 questions
9
votes
1 answer
Analyzing time complexity for change making algorithm (Brute force)
I'm new to analyzing time complexities and I have a question. To compute the nth fibonacci number, the recurrence tree will look like so:
Since the tree can have a maximum height of 'n' and at every step, there are 2 branches, the overall time…
Bugaboo
- 193
- 1
- 4
6
votes
2 answers
Why does the order of the nested loops matter when solving the Coin Change problem?
The Coin Change problem is stated as:
Given an integer array coins[ ] of size N representing different
denominations of currency and an integer sum, find the number of ways
you can make sum by using different combinations from coins[ ].
Note:…
Elad Maimoni
- 171
- 7
5
votes
2 answers
Can counting problems have optimal substructure?
I understand that for a problem to be solvable using dynamic programming, it needs to have the following properties:
optimal substructure
overlapping subproblems
I stumbled upon an article which states that:
Counting problems cannot exhibit…
Izaan
- 220
- 1
- 8
3
votes
3 answers
Find the lexicographically smallest order of N numbers such that the total of N numbers <= Threshold value
GIven a number N, Threshold T and an array A. Find the lexicographically smallest order of N numbers from A such that the total of these N numbers is <= T.
This question is a simplification of this dynamic programming question:
It’s Tushar’s…
user248884
- 245
- 3
- 9
3
votes
1 answer
Recurrence relation of the coin change problem
I'm trying to wrap my head around the coin change problem, where you try to find the total number of ways $N$ cents can be exchanged using $M$ coins $\{C_1, C_2, ..., C_m\}$.
The recurrence relation is this:
I'm having difficulty understanding the…
MarksCode
- 214
- 3
- 8
3
votes
1 answer
A variant of coin change problem
Consider a cashier machine that takes payments in coins. We feed the machine coins one by one until the value is more than the amount we should have paid. Then the machine returns the extra amount in coins in the least number of coins possible. So…
Saeid
- 349
- 3
- 15
3
votes
2 answers
DP recurrence relations: Coin change vs Knapsack
Take:
KP recurrence relation
$ max { [v + f(k-1,g-w ), f(k-1,g)] } $ if w <= g and k>0
CCP recurrence relation
$ min {[1 + f(r,c-v), f(r-1,c)]} $ if v <= c and r>0
I don't understand (much as I've researched) exactly what the…
degausser
- 33
- 1
- 4
2
votes
1 answer
Solving "coin exchange" for coins of power values by greedy algorithm
When solving the problem of coin exchange by greedy algorithm, why will we will always have the correct result if the coin values are $1, a, a^2, \cdots, a^n$, where $a\ge 2$ and $n\gt 0$?
For example, if $a = 3$, $n =3$, we get the following coin…
BoberMod
- 123
- 4
2
votes
1 answer
Dynamic Programming for a variant of the coin exchange problem
I am interested in solving a variant of the coin exchange problem. Recall the formal definition of the coin exchange problem:
Given a value N, if we want to make change for N cents, and we have infinite supply of each of S = {S1, S2, .. , Sm}…
Octavio Castillo
- 31
- 4
2
votes
2 answers
What are applications of Coin Change problem?
I've read so many about the Coin Change problem, debates about wheather it is solvable using Greedy, Dynamic Programming and so on.
Nevertheless I cannot find an application of this problem.
What are applications of Coin Change problem?
dariodip
- 874
- 11
- 19
2
votes
3 answers
Coin Change Problem(Greedy Algorithm)
In Coin Change Problem, if the ratio of Coin Value ($\frac{Coin_(i+1)}{coin(i)}$) is always increasing then we can use Greedy Algorithm?
Example- $(1,3,4)$ are denominations of coin.
If I want to pay $Rs.6$ then the smallest coin set would be…
Dhrub Kumar
- 21
- 1
2
votes
1 answer
Min-coin change problem with limited coins
I have been assigned the min-coin change problem for homework. I have to calculate the least number of coins needed to make change for a certain amount of cents in 2 scenarios: we have an infinite supply of coins and also where we only have 1 of…
Rikus Honey
- 123
- 1
- 5
2
votes
3 answers
Algorithm for fewest number of moves with artificial minimum
I asked a question recently, but I need to be able to add an artificial minimum number of steps that can be larger than the Dijkstra minimum.
To summarize, I built an undirected graph with edges representing possible moves of 1's, 10's, 100's, etc…
David Fox
- 103
- 6
1
vote
0 answers
Reducing Coin Change Problem running time to depend on the denominations, not sum being changed
I asked my Advanced Algorithms professor recently if we could solve the coin change problem (least number of coins necessary to make change for S cents using denominations d1, d2, ... dk). I thought this might be possible using something like the…
Riggster
- 11
- 2
1
vote
0 answers
Is this solution is bad for the coin change problem?
was doing coin change problem as an assignment(didnt know before), after came with this solution i checked the solutions available couldnt find a similar one like this, just curious.
removing the element from the list is O(N) so seems this also…
Ntwobike
- 111
- 1