Assume that you were given N cents (N is an integer) and you were asked to break up the N cents into coins consisting of 1 cent, 2 cents and 5 cents. Write a dynamic programming-based recursive algorithm, which returns the smallest (optimal) number of coins needed to solve this problem. For example, if your algorithm is called A, and N = 13, then A(N) = A(13) returns 4, since 5+5+2+1 = 13 used the smallest (optimal) number of coins. In contrast, 5+5+1+1+1 is not an optimal answer. Draw the recursion tree for the algorithm where N = 7. Derive the complexity bound of the algorithm. Do not need to prove the complexity bound formally, just derive it by analyzing each component in your algorithm.
Assume that you were given N cents (N is an integer) and you were asked to break up the N cents into coins consisting of 1 cent, 2 cents and 5 cents. Write a dynamic
Draw the recursion tree for the algorithm where N = 7. Derive the complexity bound of the algorithm. Do not need to prove the complexity bound formally, just derive it by analyzing each component in your algorithm.
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 2 images