Merge sort

by Jerry Sky

2020-03-09



Example 1

T(n)=2T(n2)+O(n)T(n) = 2T(\frac{n}{2}) + O(n), przy czym a=2a = 2, b=n2b = \frac{n}{2}, d=1d = 1, log22=1\log_22 = 1
T(n)=O(nlogn)T(n) = O(n\log n)

Example 2

T(n)=9T(n3)+11n32T(n) = 9T(\frac{n}{3}) + 11\cdot n^{\frac{3}{2}}
przy czym a=9a = 9, b=3b = 3, d=32d = \frac{3}{2}
log39=2>32T(n)=O(n2)\log_3 9 = 2 > \frac{3}{2} \rightarrow T(n) = O(n^2)

Example 3

T(n)=4T(n2)+n2lognT(n) = 4T(\frac{n}{2}) + \frac{n^2}{\log n}
mamy a=4a = 4, b=2b = 2,
n2logn=O(n2)\frac{n^2}{\log n} = O(n^2)

T(n)=4T(n2)+n2\overline{T}(n) = 4\overline{T}\big(\frac{n}{2}\big) + n^2
T(n)=O(n2logn)\overline{T}(n) = O\big(n^2 \log n\big)
T(n)=O( T(n) )=O(n2logn)T(n) = O\big(~\overline{T}(n)~\big) = O\big(n^2 \log n\big) \leftarrow może być za duże