You are given N cents (integer N) Break up N cents into coins of 1 cent, 2 cent, 5 cents. Using a recursive algorithm (ordinary recursion), return the smallest number of coins needed to do this. (Ex: if your algorithm is called B, and N = 13, then B(N) B(13) returns 4, since 5+5+2+1 = 13 used the smallest number of coins. In contrast, 5+5+1+1+1 is not an optimal answer.) Draw the recursion tree for this when N = 7. Derive complexity bound of algorithm, no proving needed just derive it by going through each component in the algorithm.

icon
Related questions
Question
You are given N cents (integer N)
Break up N cents into coins of 1 cent, 2 cent, 5 cents. Using a recursive algorithm (ordinary recursion), return the
smallest number of coins needed to do this.
(Ex: if your algorithm is called B, and N = 13, then B(N) B(13) returns 4, since 5+5+2+1 = 13 used the smallest
number of coins. In contrast, 5+5+1+1+1 is not an optimal answer.)
Draw the recursion tree for this when N = 7. Derive complexity bound of algorithm, no proving needed just derive it by
going through each component in the algorithm.
Transcribed Image Text:You are given N cents (integer N) Break up N cents into coins of 1 cent, 2 cent, 5 cents. Using a recursive algorithm (ordinary recursion), return the smallest number of coins needed to do this. (Ex: if your algorithm is called B, and N = 13, then B(N) B(13) returns 4, since 5+5+2+1 = 13 used the smallest number of coins. In contrast, 5+5+1+1+1 is not an optimal answer.) Draw the recursion tree for this when N = 7. Derive complexity bound of algorithm, no proving needed just derive it by going through each component in the algorithm.
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer