Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Data Structures and Algorithm Analysis2d arrays in Java. This program will return the smallest number of coins. There are 3 different type of coins. We have 10cent coin, 6 cent coin, and 1 cent coins. For example if i wanted to give 12 cents, using the 3 coins, i will give 2 coins of 6cents coin and 6cents coin which make up 12 cents. 10 cents coin 6 cents coin 1 cent coin if i wanted to give 9 cents, the least number i can give is 4 coins. i will give 6cent coin + 1cent coin+1cent coin+1cent coin total 9 cents with 4 coins. For this assignment, you will have to use 2d array to setup the coins. row 1 has 3 coins that return the least # of coin row 2 has 2 coins(6cent coin and 1 cent coin) row 3 has only 1 cent coin please also provide algorithm or flow chart If you have any further question please contact me via email.Coin Changing Problem:

Develop a program that makes change for an amount A using the fewest number of coins, where the available denominations were

denom[1] > denom[2] > ... > denom[n] = 1

You cannot use the following greedy algorithm, which may or may not lead to an optimal solution, i.e. the fewest number of coins, depended on which denominations of coins were available.

Greedy_coin_change(denom, A) { i = 1;

while (A > 0) {

c = A/denom[i];
println("use " + c + " coins of denomination " + denom[i]); A = A - c * denom[i];
i = i + 1;

}

}

Instead, you are required to develop a dynamic-programming solution for the coin-changing problem no matter which denominations are available.

According to dynamic programming, you can break the given problem into subproblems by considering the i, j-problem of computing the minimum number of coins for an amount j, 0 <= j <= A, where the available denominations are

denom[i] > denom[i+1] > ... > denom[n] = 1, 1 <= i <= n

The original problem is i = 1 and j = A. We let C[i][j] denote the solution to the problem; that is, C[i][j] is the minimum number of coins to make change for the amount j, using coins i through n. The following table shows an example: the array C for the denominations denom[1] = 10, denom[2] = 6, and denom[3] = 1 and amount up to 12. The index i specifies that coins i through 3 are available, and j is the amount. When i = 3, only of the coin of denomination 1 is available. Thus, in the last row, it takes j coins to make change for the amount j. When i = 2, the coins 6 and 1 are available. For example, the minimum number of coins to make change for the amount 8 is three---one coin of denomination 6 and tow coins of denomination 1. When i = 1, all of the coins are available. For example, the answer for the amount 11 is two---one coin of denomination 10 and one coin of denomination 1.

i, j    0           1        2        3        4         5         6        7         8        9         10    11    12

1

0

1

2

3

4

5

1

2

3

4

1

2

2

2

0

1

2

3

4

5

1

2

3

4

5

6

2

3

0

1

2

3

4

5

6

7

8

9

10

11

12

To solve the i,j-problem, i < n, we must decide whether to use a coin of denomination denom[i]. if we do not use denom[i], we, in order to achieve the amount j, must solve (i+1), j-problem that is a subproblem (a smaller problem in the sense that fewer coins are available). In this case C[i][j] = C[i+1][j]. On the other hand, if we use denom[i], we must complete the solution by making change for the amount j-denom[i] using coins of denom[i], denom[i+1], ..., denom[n] = 1; that is a i, (j-denom[i])-problem.

Thus depended upon whether coin i should be used, the solution to the i,j-problem is?

Deliverables

1. Well written algorithm or flow chart of your program

2. The source code and testing data including inputs and outputs

 

3. The class or executable file

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91868220
  • Price:- $20

Priced at Now at $20, Verified Solution

Have any Question?


Related Questions in Computer Engineering

In unix programming ordinarily the exec system call follows

In UNIX programming, ordinarily the exec() system call follows the fork() call. Explain what would happen if a programmer were to inadvertently place the call to exec() before the call to fork().

I really need help writing this c progam i have seen many

I really need help writing this C++ progam. I have seen many answers to this question on this site, but they are all deeply flawed. Design the following classes in C++. Person class is the base class for other classes. P ...

Need help with a java program that takes two arrays a and b

Need help with a Java program that takes two arrays a and b of length 5 storing int values, and returns the dot product of a and b. That is, it returns an array c of length n such that c[i]=a[i]*b[i].

Espn pays the nfl 11 billion per year for 8 yrs for the

ESPN pays the NFL $1.1 Billion per year for 8 yrs for the right to exclusively televise football. What is the NPV of the investment if the parent Disney CO has an opportunity interest rate that is equal to the cost of ca ...

Give examples of how dominos has adapted its global

Give examples of how Domino's has adapted its global marketing mix to meet the needs of local consumers. Are you their customer? If so, why?

Can someone help me with thiswrite your own class called

can someone help me with this Write your own class called WeatherStats to manage the ordered collection of high temperatures. Have two constructors, one for a default maximum size collection of 10, and the second for a u ...

Are us executives paid too much particularly compared to

Are U.S. Executives paid too much particularly compared to the average worker in their organization?

Without doing any math or drawing a graph which is bigger

Without doing any math, or drawing a graph, which is bigger, compensating variation or equivalent variation for a tax? Consider an individual with Cobb-Douglas preferences over some good and all other goods. In what sens ...

One of the authors received a credit card bill for 2988 but

One of the authors received a credit card bill for 2,988, but it included a charge of 1,834 that was not valid. Find the values of the absolute and relative errors the absolute value is 1,834 what is the relative errors?

Discuss how the scope of computer security grew from

Discuss how the scope of computer security grew from physical security to include : Securing the data Limiting random and unauthorized access to that data. Involvement of personnel from multiple levels of the organizatio ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As