Making Change: Given coins of denominations (value) 1 = v1 <
v2< … < vn, we wish to make change for an amount A using as
few coins as possible. Assume that vi’s and A are integers. Since
v1= 1 there will always be a solution.
Formally, an algorithm for this problem should take as input:
An array V where V[i] is the value of the coin of the ith
denomination.
A value A which is the amount of change we are asked to
make
The algorithm should return an array C where C[i] is the number of
coins of value V[i] to return as change and m the minimum number of
coins it took. You must return exact change so

The objective is to minimize the number of coins returned or:

a) Describe and give pseudocode for a dynamic programming algorithm
to find the minimum number of coins to make change for A.
b) What is the theoretical running time of your algorithm?
Answer:
a)
M(j) = the minimum number of coins required to make change for an amount of money j
M(j) = min{M(j − vi )} + 1
The smallest number of coins required to make j , is the smallest number required to make j − vi , plus one.
Algorithm Minimum-Change(C,v)
//all of vi and C are positive integers.
Input: n types of coin denominations of values v1 < v2 < ... < vn
Output: The minimum number of coins required to make change for an amount of money j
M[0]ß0
{M[j]← ∞ where i<0}
for jß1 to C do
Min← ∞
for iß1 to |V| do
if M[j-v[i]] +1< min then
minßM[j-v[i]] +1
end if
end for
return M[C]
end for
b)
The theoretical running time of the above algorithm is O(n * A)
Please provide your valuable feedback.
Making Change: Given coins of denominations (value) 1 = v1 < v2< … < vn, we...
Suppose you have a set of coins of various denominations, with values v1, v2, …, vn. Some of the coins may have the same value as other of the coins (or maybe not, for the purpose of this problem it doesn’t matter). I want to use these to buy an item that costs exactly M. That is, I want to find out if there is some subset of the coins whose values will sum to exactly M. (Note that I...
Recall the coin changing problem: given coins of denomination di zonks, where 1 = d1 < d2 < ··· < dk, and infinitely many coins of each denomination, find the minimum number of coins needed to make exact change for n zonks. Here we ask a different problem. Each coin has a weight, the weight of each coin with denomination di being wi > 0. We want to make exact change while minimizing the total weight of the coins used....
design algorithm and say what the big O is by analying it When making change, we want to give the least number of coins as possible. Design an O(number of denominations) algorithm that does this for any set of coin denominations. You can assume that the denominations are sorted from low to high, and will always have a penny (and so every amount of change will be possible). You can also assume that the coins are all powers of some...
Suppose we want to make change for N cents, using the least number of coins of denominations {1, 5, 10} cents (Different from the US currency system!). Consider the following greedy strategy: suppose the amount left to change is M, take the largest coin that is no more than M; subtract this coin's value from M, and repeat. Implement the Greedy Coin Changing Algorithm in Java. public class Coinchange { public static int greedycoinchange(int givenvalue, int[] givencoins) {...
The post office sells stamps of a variety of different denominations (values), and different sizes. Consider a set of n stamps, where each stamp i has a specific denomination di and a size si . All denominations are distinct. All input numbers are positive integers. We can use stamp denominations multiple times. When buying stamps that total to a given postage amount P, we want to minimize the total size of the stamps (to leave the most addressing space on...
Problem: Implement (in C) the dynamic program algorithm for the coin-change algorithm, discussed in class. Assume that the coins with which you make change are quarters, dimes, nickels and pennies. Thus you are going to set n = 4 in your program. The amount k for which you have to make change will be provided by the user and your program will return the minimum number of coins needed and also the break-up of the change in terms of the...
Suppose we want to make change for n cents, using the least number of coins of denominations 1, 10, and 25 cents. Consider the following greedy strategy: suppose the amount left to change is m; take the largest coin that is no more than m; subtract this coin's value from m, and repeat. Either give a counter example, to prove that this algorithm can output a non-optimal solution or prove that this algorithm always outputs an optimal solution.
Consider the problem of finding change using as few coins as given coins: lc, 2c, 5c. The goal is to determine the minimum number of coins that add up possible. Formally we are input non-negative integer n, and we have unlimited quantities of 3 types of as a. to nc. Your task is to design programming (a) [6 marks] Clearly define your DP states (subproblems) O(n) time algorithm for solving this problem using dynamic an (base and recursive cases) (b)...
5. (3 points) Consider a hypothetical country Binary Land where they only use coins. There are n types of coins of denominations 1, 21, 22, 2,..., 2-1. Suppose you are a bank teller in Binary Land and your job is to give money to customers for any requested value V that is an integer. You should minimize the number of coins while paying V units of money. Design an algorithm that takes V as input and outputs the payment method...
1. Minimization and Maximization Problems Which of the following best describes the role of the greedy approach in minimization (min) and maximization (max) optimization problems? A) The greedy approach never works for min or max problems B) The greedy approach never works for min problems but may work for max problems C) The greedy approach never works for max problems but may work for min problems D) The greedy approach may work for min and max problems E) The greedy...