Vidyalelo
Data Structure · Q298

Dynamic Programming in Data Structures

Programming · Data Structure · question 298

Q298

Consider the following code to find the nth fibonacci term using dynamic programming: 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] Which technique is used by line 7 of the above code?

A.
Greedy
B.
Recursion
C.
Memoization
Answer
D.
Overlapping subproblems

Answer: Option C

Solution

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