Describe an algorithm which gives initial amount , Macroeconomics

Assignment Help:

This problem involves the question of computing change for a given coin system. A coin system is defined to be a sequence of coin values v1 < v2 < . . . < vn, such that v1 = 1. For example, in the U.S. coin system we have six coins with values h1, 5, 10, 25, 50, 100i. The question is what is the best way to make change for a given integer amount A.

(a) Let c ≥ 2 be an integer constant. Suppose that you have a coin system where there are n types of coins of integer values v1 < v2 < . . . < vn, such that v1 = 1 and, for 1 < i ≤ n, vi = c · vi-1. (For example, for c = 3 and n = 4, an example would be h1, 3, 9, 27i.) Describe an algorithm which given n, c, and an initial amount A, outputs an n-element vector that indicates the minimum number of coins in this system that sums up to this amount. (Hint: Use a greedy approach.)

(b) Given an initial amount A ≥ 0, let hm1, . . . ,mni be the number of coins output by your algorithm. Prove that the algorithm is correct. In particular, prove the following:

(i) For 1 ≤ i ≤ n, mi ≥ 0

(ii) Pn

i=1mi · vi = A

(iii) The number of coins used is as small as possible

Prove that your algorithm is optimal (in the sense that of generating the minimum number of coins) for any such currency system.

(c) Give an example of a coin system (either occurring in history, or one of your own invention) for which the greedy algorithm may fail to produce the minimum number of coins for some amount.

Your coin system must have a 1-cent coin.

Hint on problem 3: Suppose that the input is n=4, c=2, A=53 (meaning four coins, growing exponentially in 2, that is, {1, 2, 4, 8}, and 53 cents as the amount). The output would be (1,0,1,6), meaning:

The input consists of n, c, and the amount A. The output is a list of the numbers of coins of each denomination that sums to A.


Related Discussions:- Describe an algorithm which gives initial amount

Using algebra find the equilibrium price, The demand equation for champagne...

The demand equation for champagne is given by P = 10 - Q. The supply schedule for champagne is given by P = Q. Note that P denotes price per bottle in dollars, and Q is quantity me

Consumers become better educated about the products, How can consumers beco...

How can consumers become better educated about the products they are considering for purchase? To what extent do you personally go to acquire the best information available?

Total public debt outstanding, What was the total public debt outstanding o...

What was the total public debt outstanding on the same day in 2000? What was it in 2008?

Overall effect of a change in real wages, Q. Overall effect of a change in ...

Q. Overall effect of a change in real wages? The supply of labor The supply of labour L S is assumed to be positively related to the real wage W/P

Fiscal Policy, What are the effects of the fiscal stimulus on the macroecon...

What are the effects of the fiscal stimulus on the macroeconomy

Describe exports and imports in as-ad model, Q. Describe Exports and import...

Q. Describe Exports and imports in AS-AD model? Exports and imports. This is more difficult to justify owing to exchange rate. Suppose that we have a flexible exchange rate a

Calculate the equilibrium price and quantity, Question 1: What is the equi...

Question 1: What is the equilibrium price and quantity? Question 2: How do you describe the market situation, if the market price is higher than the equilibrium price? Qu

Serve on an environmental policy, Suppose you serve on an environmental pol...

Suppose you serve on an environmental policy planning board for the federal government. Your task is to propose a policy initiative aimed at reducing urban air pollution, using the

Explain why interest rates are pro-cyclical, Critically explain why interes...

Critically explain why interest rates are pro-cyclical, using the supply and demand for bonds framework.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd