Question: Exercise 1 . Hopping Up Steps - recursive formula We are given the following problem: figure out how many ways we can hop up n

Exercise 1. Hopping Up Steps - recursive formula
We are given the following problem: figure out how many ways we can hop up n steps, if at every point we can make one hop of d steps, where d is one of the following {d1,d2,dotsdk}?
For example, if we can hop either one or two steps at a time, there are FIVE valid ways to hop 4 steps: {1,1,1,1},{2,1,1},{1,2,1},{1,1,2},{2,2}.
This problem is somewhat similar to the problem of finding out the minimum number of coins to make change for amount n with denominations {d1,d2,dotsdk}.
Note: When k is 1(there is only one type of hop to make), the answer should not be more than 1.
a) Find the recursive formula for computing findNumWays(n,{d1,d2,dotsdk}).
Carefully explain why your formula is correct.
b) Create working Python code for findNumWaysR, which is a recursive method based on your formula in (a), and test that it works correctly. Test it for various inputs, such as findNumWaysR (4,{1,2}) findNumWaysR(5,{17},findNumWaysR {17,{1,3,5}
Exercise 1 . Hopping Up Steps - recursive formula

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!