For positive integer denominations, the coin change problem asks for coins summing to a target amount ; this recurrence minimizes their number. With unlimited supply, use the recurrence in the title, , and for an unreachable amount. Classifying a solution by its last coin proves the recurrence by induction. Recording that coin reconstructs an optimum. The table uses running time and space complexity; this is a pseudopolynomial time bound.
If each available coin can be used only once, update for amounts in descending order for each coin. Descending order retains the previous row's value at and prevents reuse. Ascending order instead permits repeated use of the current coin. The distinction is a dependency invariant, not a cosmetic loop-order choice.
For denominations and with , greedy minimizes coin count. Among optimal representations choose a lexicographically maximal descending denomination-count vector. Two unit coins can be replaced by one two; two below the largest can be replaced by without increasing count but improving that vector. Thus all smaller denominations occur at most once. For the coins below , write their value as , where is their count and is the sum of their distinct power-of-two parts. If , one and units use coins, contradicting optimality. Therefore the residual below each denomination is smaller than it, forcing precisely the greedy quotients.
Articles by others on the same topic
There are currently no matching articles.