Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help me to solve the problem with java language! Write functions called coinChangeDP and coinChangeGreedy that take an array of coin denominations and an
Please help me to solve the problem with java language!
Write functions called "coinChangeDP" and "coinChangeGreedy" that take an array of coin denominations and an amount of change. The functions will attempt to return the minimal number of coins necessary to make the specified amount of change using the specified denominations. (The DP result will be minimal, while the greedy one will not.) for example, the signature of the methods would look like this shown below =>
public static int coinChangeDP(int[] coinValues, int change) public static int coinChangeGreedy(int[] coinValues, int change)
The code used to test your function will look similar to this:
int[] coins = {50,25,10,5,1}; for(int i=1; i<=55; i++) { System.out.print(i + "\t"); System.out.print(coinChangeDP(coins, i) + "\t"); System.out.println(coinChangeGreedy(coins, i)); }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started