Vidyalelo
Data Structure · Q157

Dynamic Programming in Data Structures

Programming · Data Structure · question 157

Q157

What is the time complexity of the following dynamic programming implementation used to compute the nth fibonacci term? 1. int fibo(int n) 2. int fibo_terms[100000] //arr to store the fibonacci numbers 3. fibo_terms[0] = 0 4. fibo_terms[1] = 1 5. 6. for i: 2 to n 7. fibo_terms[i] = fibo_terms[i - 1] + fibo_terms[i - 2] 8. 9. return fibo_terms[n]

A.
O(1)
B.
O(n)
Answer
C.
O(n2)
D.
Exponential

Answer: Option B

Solution

Answer: Option B
No explanation is given for this question Let's Discuss on Board