Question: The terms in the Fibonacci sequence are given by : F(1) = 1, F(2) = 1; F(n)= F(n-1) + F(n-2) (a) Give the pseudo-code for
The terms in the Fibonacci sequence are given by : F(1) = 1, F(2) = 1; F(n)= F(n-1) + F(n-2)
(a) Give the pseudo-code for a recursive algorithm to calculate the nth term in the Fibonacci sequence. (b) Give the pseudo-code for a dynamic programming algorithm to compute the nth term in the Fibonacci sequence. (c) What is the running time of the DP algorithm. (d) How does this compare to the running time of the Recursive algorithm?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
