A country has coins with k denominations 1 = d1 < d2 < ... < dk, and you want to make change for n cents using the smallest number of coins.
For example, in the United States we have d1 = 1, d2 = 5, d3 = 10, d4 = 25, and the change for 37 cents with the smallest number of coins is 1 quarter, 1 dime, and 2 pennies, which are a total of 4 coins.
To solve for the general case (change for n cents with k denominations d1 ... dk), we refer to dynamic
1. We will come up with sub-problems and recursive relationship for you. Let be the minimum number of coins needed to make change for n cents, then we have:
Explain why the above recursive relationship is correct. [Formal proof is not required]
2. Use the relationship above to design a dynamic programming algorithm, where the inputs include the k denominations d1 ... dk and the number of cents n to make changes for, and the output is the minimum number of coins needed to make change for n.
Provide the pseudocode of your algorithm and briefly justify the runtime of your algorithm using big-O notation.
3. Adapt your algorithm above by tracking some useful information during the DP procedure, so that it returns the actual method (i.e., the number of coins for each denomination) to change for n cents, not just the minimum number of denominations.
Step by stepSolved in 4 steps
- Consider the following program, in which a, b, and c are the last 3 digits of your student ID number (for example, if you student ID is 170123456, then you should substitute 4 for a, 5 for b, and 6 for c in the program): maximise axı + 3x2 + x3 subject to -bx1 – x2 + 2x3 > 6 -x2 + x3 = 1 - cx1 + 2x2 – 2x3 0 (i) Give the initial starting tableau for the 2-phase simplex algorithm for this program. (ii) Carry out the 2-phase simplex algorithm on this problem. You should give an optimal solution to the program or say why an optimal solution does not exist. Show your work and explain how you determined if the program is feasible or not at the end of the first phase.arrow_forwardIn the game of 10-pin bowling the bowler has two attempts to knock down pins for every frame of 10-pins, and scores a point for each pin knocked down. If all the pins are knocked down with two attempts, the bowler gets a bonus - whatever score they obtain with their next bowl is doubled. If all the pins are knocked down on the 1st attempt, no 2nd attempt is allowed, and the bowler gets a bonus – whatever score they obtain on their next two bowls are doubled. A student attempts to capture this scoring system in VHDL code, a fragment of which is shown in Figure Q4. Q4 (a) Draw the state transition diagram described by the VHDL of Figure Q4. Discuss whether the VHDL of Figure Q4 correctly scores a game of 10-pin bowling. (b) elsif CLK='1' and CLK'event and UPD='1' then case present state is when throwl => frame := frame + 1; + resize (unsigned (N), 9) score := score if N = w1010" then present state score := score + resize (unsigned (N), 9) present state + resize (unsigned (N),9) if N =…arrow_forwardI need to write a program for a Lion Hunt. The program should calculate the number of hours it will take a group of hunters to find the lion in the worst case scenario. We asumme that The lion has b b Hiding spots where 2 ≤ b ≤ 10 , 000 2 ≤ b ≤ 10 , 000 . We assume that there are s s Hunters where 1 ≤ s ≤ 1 , 000 1 ≤ s ≤ 1 , 000 . We assume that there are g g number of hunters, who need to be in a group to travel safely where 1 ≤ g ≤ s 1 ≤ g ≤ s . We assume that it takes a group 1 hour to search any of The lions hiding spots The input consists of a single line containing three integers ?, ? and ?, where 2≤?≤1000 is the number of hiding spots in the jungle. 1≤ e. Sample input/output is shown in attached photoarrow_forward
- Consider the software that runs in an Automated Teller Machine (ATM) machine. One task that must be able to be performed is to determine the type (denomination) of currency and the numbers of bills (aka “banknotes” for those of you not from North America) for each type dispensed. A requirement is that our ATM use the fewest number of bills that it can to dispense the specified amount of money. It only dispenses fifties, twenties, tens, fives, and ones. Design and implement program that writes out what bills would be dispensed if this machine existed for the amount of money that was asked for by the user.Test CasesIn the comments at the top of your file, list 3 test cases that you came up with. Something like this but choose your own examples. You should write your test cases in such a way that, if they all pass, you can be fairly confident your program will work all the time. '''Test case #1:Input: $1Output: 0 fifties, 0 twenties, 0 tens, 0 fives, 1 onesTest case #2:Input: $22Output:…arrow_forwardIn a hypothetical study of population dynamics, scientists have been tracking the number of rabbits and foxes on an island. The number of rabbits and foxes are determined once a year using high resolution infrared cameras and advanced computer vision methods.Each year, the number of rabbits and foxes are found to change by the following equations: $$ {\Delta}R = round( kr*R - krf*R*F ) $$ $$ {\Delta}F = round( -kf*F + kfr*R*F ) $$ where $ {\Delta}r $ and $ {\Delta} f $ are the changes in number of rabbits and foxes by the end of that year; and R and F are the population sizes at the end of the previous year. kr, krf, kf, kfr are coefficients that depend on the species of rabbits and foxes.With these dynamics, the scientists realize that one or both species can become extinct on the island. At the end of each year, if there are fewer than 2 animals of a kind, the scientists transfer rabbits and/or foxes to make sure there are at least 2 of each kind.Write a function…arrow_forwardLet A = {1, 13, 100} and B = {7, 13}. Then: (d) What is the powerset of B? (e) What is { (f) What is { € A | Vy € B, x > y} € A ³y € B,x > y}arrow_forward
- The Mayfree Appliance Company requires sheet metal for its appliances. The company can purchase long coils of sheet metal in two different widths: 65 inches and 40 inches. The company must purchase the coils by linear foot of length: $1.20 per foot for a 64-inch coil and $1.00 per foot for a 40-inch coil. (This implies that a square foot, say, of the wider coil is less expensive.) Up to 4000 feet of the 65-inch coil is available, and up to 6000 feet of the 40-inch coil is available. There are manufacturing requirements for six different widths: 50, 45, 40, 35, 20, and 10 inches. Mayfree’s requirements are expressed as lengths of the various widths. The company requires 1000 feet of 50-inch width, 2500 feet of 45-inch width, 3000 feet of 40-inch width, 2300 feet of 35-inch width, 1300 feet of 20-inch width, and 2000 feet of 10-inch width. Determine how much of each width coil Mayfree should purchase and how it should cut the coils into various widths to meet its requirements at minimal…arrow_forwardMore and more seafood is being farm-raised these days. A model (differentialequation) used for the rate of change for a fish population, P(t) in farmingponds is given by P'(t) = b(1-(P(t)/Pm)) - hP(t) where b is the birth rate, PM is the maximum number of fish the pond cansupport, and h is the rate the fish are harvested. Write a python code that implements the Forward Euler method to solve thedifferential equation Suppose that the carrying capacity PM = 20, 000 fish with a birth rateof 6% and a harvesting rate of h = 0%, use your Python code to findand plot the numerical solution for the first 400 days for different valuesof y0. Pick y0 < 20, 000, y0 > 20, 000. Don’t forget to label all your plotswith x and y axes label, titles and legends. Use a time step ∆t = 0.1arrow_forwardNonearrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education