Question

Answer this question using recursion. Show step by step to solve this question

1. F(n) = F(n-1) + F(n-2)

where:

F(0) = 0 F(1) = 1

Answer #1

First of all we need to understand here what recursion is ??

So recursion is performing similar task again and again until we don't reach to the condition where we can terminate or in programming terms we say it as base case.

So here in your question we have to calculate F(n) which is equivalent to F(n-1) + F(n-2).

Here if you will look closely than F(n-1) is same as F(n) but the only difference is of n as it gets decremented by 1 here ,same is the case with F(n-2).

But hold on lets think for a second .

Take n=10

Now according to the question F(n) will call first F(n-1) i.e F(9) than F(9) will call F(8) and this procedure will go on forever .....is this the case??

NO!

So to get rid of this problem we are provided with the BASE CASES i.e as soon as we reach at the base case we can return from there .

So here as soon as n reaches 0 or 1 it returns 1 from there and than other recursion calls take place.

Diagramatically the recursion calls work as follow:

Taking n=5

For your info i may tell you that above equation is a well known problem of recursion as if referred as FIBONACCI SEQUENCE.

SO F(5) will call F(4) and F(3)

then first F(4) calls will occur then after it recieves its answer than F(3) calls will occur then finaaly after summing both values we are going to get the answer.

AS you can see in the diagram -- first the nodes of the tree that are on the left are called first then the nodes of the trees on the right are called .

Hope it clarify your doubts and now you will have no problem regarding recursion.

**Please upvote my answer as it will give the boost to
write more quality answers!!**

Solve this recurrence using recursion tree :
1)T(n)=T(n/2)+2^n
2)T(n)=16(n/4)+n

Solve f(n) as a function of n using the homogeneous equation and
given the conditions below:
f(0) = 0;
f(1) = 1;
f(2) = 4;
f(n) = 2 f(n-1) - f(n-2) + 2; n >
2

The language is C.
What is function(9)? Use a recursion tree to find the
answer.
int function(int n) {
If (n<=1)
return 1;
If (n%2==0)
return f(n/2);
return f(n/2) + f((n/2)+1);
}

Can someone explain how I solve for PV=F*(P|F,i,n)+A*(P|A,i,n)
step by step?

Please Solve with using BA2Plus Financial calculator. Show
step by step.
Question 6 – PV, Ordinary Annuity, Compounding [2 points]:
Find the present value of the following ordinary annuities:
a) PV of $300 each six months for five years at a simple rate
of 12 percent, compounded semiannually
b) PV of $150 each three months for five years at a simple
rate of 12 percent, compounded quarterly

How to solve this equation to find f(n), where
f(n)=1+p*f(n+1)+q*f(n-1). p,q are constant and p+q=1. We already
know two point f(0)=f(d)=0, d is a constant number.
what is f(n) as a function with p,q,d,n?

Please show complete, step by step
working.
Solve the following equations for 0 ≤ x ≤ 2π, giving
your answers in terms of π where appropriate
i) cos
x = -√3/2
ii) 2 sin
2x = 1
iii) cot x =
1/√3
b) Solve the following for 0° ≤ q ≤
360°,
i) sin^2Q = 3/4
ii) 2 sin^2Q - sinQ = 0 {Hint: factor out sinθ)

Give a recursive algorithm to solve the following recursive
function.
f(0) = 0;
f(1) = 1;
f(2) = 4;
f(n) = 2 f(n-1) - f(n-2) + 2; n
> 2
Solve f(n) as a function of n using
the methodology used in class for Homogenous Equations. Must solve
for the constants as well as the initial conditions are given.

QUESTION 1
For the following recursive function, find f(5):
int f(int n)
{
if (n == 0)
return 0;
else
return n * f(n - 1);
}
A.
120
B.
60
C.
1
D.
0
10 points
QUESTION 2
Which of the following statements could describe the general
(recursive) case of a recursive algorithm?
In the following recursive function, which line(s) represent the
general (recursive) case?
void PrintIt(int n ) // line 1
{ // line 2...

Design & Analysis of Algorithimns
Resolve these
1) F(n) = F(n-1) + F(n-2)
where:
F(0) = 0
F(1) = 1
2) t(n) = 6t(n-1)+4t(n-2)
where:
t(0)=0
t(1)=4sqrt

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 9 minutes ago

asked 21 minutes ago

asked 24 minutes ago

asked 38 minutes ago

asked 47 minutes ago

asked 49 minutes ago

asked 54 minutes ago

asked 1 hour ago

asked 2 hours ago

asked 2 hours ago

asked 3 hours ago

asked 3 hours ago