Question
This is exercise 20 in chapter 2 - but this time i would need to Repeat Exercise 20 in Chapter 2 , using the ADT
This is exercise 20 in chapter 2 - but this time i would need to Repeat Exercise 20 in Chapter 2 , using the ADT list to implement the function f (n).
Consider the following recurrence relation:
F (1) = 1; f (2) = 1; f(3) =1; f(4) =3; f(5) = 5;
f (n) = f( n -1 ) + 3 x f(n-5) for all n > 5
Compute f(n ) for the following values of n : 6, 7, 12, 15.
If you were careful, rather than computing f (15) from scratch (the way a recursive C++ function would compute it), you would have computed f (6), then f (7), then f(8), and so on up to f(15), recording the values as you computed them. This ordering would have saved you the effort of ever computing the same value more than once. (Recall the iterative version of the rabbit function discussed at the end of this chapter.) Note that during the computation
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started