Skip to content
Related Articles

Related Articles

Improve Article

ISRO | ISRO CS 2017 | Question 18

  • Last Updated : 28 Mar, 2018

Consider the recurrence equation

T(n) = 2T(n-1), if n>0
     = 1, otherwise

Then T(n) is (in big O order)
(A) O(n)
(B) O(2n)
(C) O(1)
(D) O(log n)


Answer: (B)

Explanation: Using Substitution Method:
T(n) = 2T(n-1)
= 2(2T(n-2)) = 2^2T(n-2)
= 2(2^2T(n-2)) = 2^3T(n-3)
....
= 2(2^{n-3}T(n-(n-2))) = 2^{n-2}T(n-(n-2))
= 2(2^{n-2}T(n-(n-1))) = 2^{n-1}T(n-(n-1)) = 2^{n-1}T(1)
= 2(2^{n-1}T(n-(n))) = 2^{n}T(n-(n)) = 2^{n}T(0)
T(n) = O(2^n)

So, option (B) is correct.

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :