In: Computer Science
Complete the following recursively defined functions.
Base case ?(0)=3
Recursive case ?(?) = 3?(? − 1) + 7 for n ≥ 1.
?(1) = ______
f(2) = _______
f(3) = ______
f(4) = ______
Base case ?(0)=1, ?(1)=2
Recursive case ?(?) = ?(? − 1)?(? − 2) for n ≥ 2.
g(2) = ______
g(3) = ______
g(4) = ______
g(5) = ______
So, as we have to give the value of the functions given in the question.
So, let's get started:
It is given that for n = 0, f(0) = 3,and the recursive function is,
f(n) = 3f(n-1) + 7 for n>=1
Now, to find values of this function at different values we are going to put the value of n in the function:
Hence, f(1) = 3*f(1-1) + 7
= 3*f(0) + 7
= 3*3 + 7 ----->(f(0) = 3, given)
= 16.
Now, f(2) = 3*f(1) + 7
= 3*16 + 7 ------>(f(1) = 16, we calculated)
= 55
and, f(3) = 3*f(2) + 7
= 3*55 + 7
= 172
and f(4) = 3*f(3) + 7
= 3*172 + 7
= 523
So, this was all about the values of f for different values.
Now, let's discuss about the function g:
It is given that for n = 0, g(n) = 1 and for n = 1, g(n) = 2 ,and the recursive function is,
g(n) = g(n-1)*g(n-2) for n>=2
Now, to find values of this function at different values we are going to put the value of n in the function:
Hence, g(2) = g(2-1)*g(2-2)
= g(1)*g(0)
= 2 * 1 ----->(g(0) = 1 and g(1) = 2, given)
= 2.
Now, g(3) = g(2) * g(1)
= 2 * 2 ------>(g(1) = 2,given and g(2) = 2, we calculated)
= 4
and, g(4) = g(3) * g(2)
= 4 * 2
= 8
and g(5) = g(4) * g(3)
= 8 * 4
= 32
So, this was all about the values of g for different values.
So, this was the solutions of the problem.
I hope I am able to solve your problem, if yes then do give it a like.
It really helps :)