Problem: Consider you have infinite coins of denominations {1p, 7p, 10p} and a sum S. Design a dynamic programming algorithm that will find the minimum number of coins required to get the sum S. For example: For some values of S there could Sum Minimum number One Solution certainly be more than one way to (S) of coins do this 2 2 Two 1p 3 3 Three 1p 5 1 Five 1p 7 3 One 7p 8 4 One 7p, one 1p 10 1 One 10p 45 6 One 1p, two 7p, three 10p 63 9 Nine 7p six 10p and three 1p
Your solution should be built as follows: 1. (10 points) Design and implement a recursive solution. 2. (10 points) Show that this problem can be solved using dynamic programming. This can be done by drawing the recursion tree for a specific example and show that some sub-problems are recalculated again and again. 3. (20 points) Explain the main idea that forms the heart of the dynamic programming algorithm that you will use. You should a. Show the table that you will use (its, dimension, what is the meaning of numbers stored in its cells) b. Explain an example of how to fill the table C. Write down the general formula that you used to fill the table (the base cases and the general case) 4. (40 points) Implement the dynamic solution to a. Find the minimum number of coins b. Find the solution (which coins are used?) 5. (15 points) What is the running time of the above three algorithms? 6. (5 points) What is the space complexity of the above three algorithms?