Examveda

What is the space complexity of the following dynamic programming implementation used to compute the nth fibonacci term?
int fibo(int n)
        int fibo_terms[100000]  //arr to store the fibonacci numbers
        fibo_terms[0] = 0
	fibo_terms[1] = 1
 
	for i: 2 to n
		fibo_terms[i] = fibo_terms[i - 1] + fibo_terms[i - 2]
 
	return fibo_terms[n]

A. O(1)

B. O(n)

C. O(n2)

D. Exponential

Answer: Option B


Join The Discussion

Related Questions on Dynamic Programming in Data Structures