next up previous
Next: Up: Previous:

Analysis

T(n) = \(\left\{ \begin{array}{ll}
\Theta(1) & n=0 \\
T(k) \;+\; T(n-k-1) \;+\; \Theta(1) & n>0
\end{array} \right.\)



k = (n-1)/2:
T(n) = T((n-1)/2) + T(n - (n-1)/2 - 1) + $\Theta(1)$
= T((n-1)/2) + T(n/2 + 1/2 - 1) + $\Theta(1)$
= T((n-1)/2) + T((n-1)/2) + $\Theta(1)$
= 2T((n-1)/2) + $\Theta(1)$
$\leq$ 2T(n/2) + $\Theta(1)$
= $\Theta(n)$



k = 0:
T(n) = T(0) + T(n-1) + $\Theta(1)$
= T(n-1) + $\Theta(1)$
= $\Theta(n)$


next up previous
Next: Up: Previous: