MergeSort Review
This is a review about MergeSort by CLRS#3 & Algorithm#4.
Complexity
- Average
$$
T(n) = \Theta(n\lg{n})
$$
<CLRS#3>
$$
T(n)=2T(n/2)+\Theta(n)
$$
Main Function
$$
T(n)=aT(n/b)+f(n)
$$
$$
1.\ T(n)=\Theta(n^{\log_b{a}}),\ if\ f(n)=n^{\log_{b}a - \varepsilon},\varepsilon>0.\
$$
$$
2.\ T(n)=\Theta(n\lg{n}),\ if\ f(n)=n^{\log_{b}a}.\
$$
$$
3.\ T(n)=\Theta(f(n)),\ if\ f(n)=n^{\log_{b}a + \varepsilon},\varepsilon>0.
$$
<Algorithm#4>
MergeSort
1 | merge(A,lo,mid,hi): |
MergeSortBU
1 | sortBU(A): |