next up previous
Next: Up: Previous:

Analysis of Merge Sort

Note if n = 1, Then T(n) = $\Theta(1)$

1.
DIVIDE computes middle of array in constant time: D(n) = $\Theta(1)$
2.
CONQUER sorts 2 subarrays of size n/2 in time: 2T(n/2)
3.
COMBINE (Merge) procedure: C(n) = $\Theta(n)$



T(n) = \(\left\{ \begin{array}{ll}
\Theta(1) & {\rm if} \; n = 1 \\
2T(n/2) + \Theta(1) + \Theta(n) & {\rm if} \; n > 1
\end{array} \right.\)



Note that $\Theta(n)$ dominates $\Theta(1)$.



We will show next class that T(n) = $\Theta(n \lg n)$, where lg = $\log_2 n$.


next up previous
Next: Up: Previous: