321 views
0 votes
0 votes
  The function for finding the fibonacci series is given as follows :

Image not present

The number of additions taken in evaluating fib(5) is.

Your Answer:

4

Correct Answer: 7    Status: incorrect

1 Answer

0 votes
0 votes
fib (5)  = fib(4) +  fib(3)

fib(4) = fib(3) + fib(2)

fib(3) = fib(2) + fib(1)   

fib(2) = fib(1) + fib(0)    

 

Now, for last simplication, 1 additions. Then we store fib(2) in fibonacci array.

For fib(3), 1 addition. Again we store fib(3).

 

And so on. This is perfect example of dynamic programming.

So, answer = 4

Related questions

276
views
0 answers
0 votes
460
views
0 answers
0 votes
UdynGP asked Feb 15, 2023
460 views
N = {0,1,2,3 .} is the set of natural numbers. In Note, it is mentioned that some people do not consider 0 as a natural number.We know that set ... the set of Natural numbers, then what is the definition of Whole numbers in that scenario?
3.2k
views
2 answers
2 votes
srestha asked Aug 30, 2018
3,221 views
$1)$3-bit ripple adder, which adds two 3-bit numbers, is designed using AND, OR, NOT, NAND, NOR gates only. Assuming that all the inputs are available in ... of each gate is one time unit, what is the overall propagation delay of the adder?
421
views
1 answers
0 votes