in Algorithms recategorized by
1,161 views
1 vote
1 vote

Consider the algorithm that solves problems of size $n$ by recursively solving two sub problems of size $n-1$ and then combining the solutions in constant time. Then the running time of the algorithm would be:

  1. $O(n)$
  2. $O(\log n)$
  3. $O(n\log n)$
  4. $O(n^2)$
in Algorithms recategorized by
by
1.2k views

1 Answer

1 vote
1 vote
recurrence relation :

T(n)=2.T(n-1)+c , n>0

T(n)=1, n=0.

as per back substitution method,

T(n) = 2$^k$.T(n-k)+ 2$^{k-1}$c+....+2$^0$c

T(n) = 2$^n$.T(0)+ 2$^{k-1}$c+....+2$^0$c

T(n) =  2$^{n+1}$-1

T(n) =  O(2$^n$)

Related questions