Examveda

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 property is shown by line 7 of the above code?

A. Optimal substructure

B. Overlapping subproblems

C. Both overlapping subproblems and optimal substructure

D. Greedy substructure

Answer: Option A


Join The Discussion

Related Questions on Dynamic Programming in Data Structures