next up previous
Next: Random-Partition Up: l4 Previous: Example

Analysis

T(n) = T(n-1) + $\Theta(n)$ in the worst case
= cn + c(n-1) + c(n-2) + ... + c
= \(c \sum_{i=1}^n i\) = \(c \frac{n(n+1)}{2}\) = \(\Theta(n^2)\)
T(n) = T(n/2) + $\Theta(n)$ in the best case
a=1, b=2, f(n) = \(\Omega(n^{log_b a + \epsilon})\), $\epsilon$ = 1



Case 3: T(n) = $\Theta(n)$
Show: 1*f(n/2) $\leq$ cf(n), c $<$ 1
f(n/2) $\leq$ c*f(n)
c $>=$ 1/2


next up previous
Next: Random-Partition Up: l4 Previous: Example