Question: Question 4 : Counting Change Recall the CountChange procedure that we saw in class. In this problem, we are given coins of n denominations, d
Question : Counting Change
Recall the CountChange procedure that we saw in class. In this problem, we are given coins of
denominations, dots,in cents and the goal is to find the number of ways of making
change for cents.
We denoted by CountChange the number of ways of making change for cents using coins
of denominations dots, For this function, we wrote a recursive formulation:
We observed that the total number of distinct recursive calls when starting with and
is which led to a memory requirement of and a time complexity of
Suppose now that we want to improve the running time of this procedure. One
simple idea is to observe that if we were given a and we wanted to compute the values of
CountChange CountChange dots, CountChange we could do this given the
values CountChange CountChange dots, CountChange
Using this observation, show how one can compute CountChange using a space complexity
only
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
