Data structures and algorithm analysis2d arrays in java

Assignment Help Data Structure & Algorithms
Reference no: EM131110624

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

Reference no: EM131110624

Questions Cloud

Define the ethical duties of a trial lawyer : Define the ethical duties of a trial lawyer under the legal profession
The company sustained a net loss for the year : Uncollectible accounts receivable in the amount of $22,000 were written off against the Allowance for Doubtful Accounts.
Read in the interest rate : In C++ Using a while loop, code and run a program that will calculate how long it will take $10,000.00 to become $1,000,000 with 0.08 interest rate.
How high above the center of a circle of radius 10.0 in : How high above the center of a circle of radius 10.0 in. should a light be placed so that illuminance at the circumference will be a maximum? See Fig. 27.51.
Data structures and algorithm analysis2d arrays in java : 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 t..
Organizational behaviour week discussion : Have you ever witnessed escalation of commitment in your organization--or seen it take place with governments? Why do you think that escalation of commitment continued instead of stopping support of the original decision?
Compute the surface area of t : Let T ⊂ R3 denote the doughnut-shaped surface obtained by revolving the circle (y - 2)2 + z2 = 1 around the z-axis. Give T the orientation determined by the outward unit normal. Compute the surface area of T
Compute net cash flow from operating activities : 1. The net income for Letterman Company for 2010 was $320,000. During 2010, depreciation on plant assets was $124,000, amortization of patent was $40,000, and the company incurred a loss on sale of plant assets of $21,000. Compute net cash flow from ..
Write a program in c++ to accept a string : Write a program in C++ to accept a String and print the total no of vowels in it. Also print the string in upper and lower case

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  C program to compute and display sales of a store

Modify the C program so that user inputs the buying amount. Check the user's input for validity.

  Create a hierarchy chart depicting the chosen situation

Create a hierarchy chart depicting the chosen situation. Develop a flowchart and provide a brief explanation for it. Develop an algorithm and provide a brief explanation for it

  Design an algorithm to determine best route for passenger

Consider the following problem: Design an algorithm to determine the best route for a subway passenger to take from one designated station to another in a typical urban subway system similar to those in San Francisco and New York

  Create a program to calculate each income bracket

People from 3-different income levels, A, B, and C, rated each of 2-different items with a number 0 through 10. Create a file in which each line contains the income level and item rankings for one respondent.

  Write algorithm for program to compute the sum of number

Write an algorithm for a program which will satisfy following requirements: - Asks a user how many numbers they want to calculate.

  Write a program for implementing the fcfs scheduling

Write a program for implementing the FCFS Scheduling algorithm? Write a program for simulation of SJF Scheduling algorithm?

  Database design

As with the previous exams(SQL,E-R diagram and Normalization, you may complete this assignment at any time up to its due date of December 8, 2013.

  Create ef?cient algorithm to fnd redundancies

Fnd the redundancies m1, · · · , mn that are within the available budget and that maximize probability that system works correctly. Create an ef?cient algorithm.

  Creating a database design in visio-business rules

Suppose a local college has tasked you to develop a database that will keep track of students and the courses that they have taken. In addition to tracking the students and courses, the client wants the database to keep track of the instructors te..

  Important java questions

Add a method addText to the Question class, and provide a different implementation of Choice Question that calls add Text rather than storing an array list of selections.

  Find the maximum number of bits in the sum

Suppose that the n is an exact power of two. The circuit consists of a complete binary tree of ripple carry adders, in which each node in tree adds 2-numbers.

  Write specifications using uml notation for a function

Write specifications using UML notation for a function that computes the sum of the first five positive integers in an array of  n  arbitrary integers.

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