Metoda iteracyjna

by Jerry Sky

2020-03-09


T(n)=3T(n4)+n=...T(n) = 3T(\frac{n}{4}) + n =...
T(1)=Θ(1)T(1) = \Theta(1)

...=n+3(n4+3(n42+3T(n4)))= ...= n+ 3(\frac{n}{4} + 3(\frac{n}{4^2} + 3T(\frac{n}{4}))) = n+34n+(34)2n+33T(n43)=() n + \frac{3}{4}n + (\frac{3}{4})^2n+ 3^3T(\frac{n}{4^3}) = (*)

chcemy n4x\frac{n}{4^x} czyli x=log2nx = \log_2 n

()=nk=0logn(34)k=()nk=0(34)k=4n (*) =n\sum_{k=0}^{\log n}(\frac{3}{4})^k = (**) \le n\sum_{k=0}^{\infin}(\frac{3}{4})^k = 4n czyli T(n)=O(n)T(n) = O(n)

()=n+(34)n+(34)2n+...+3log2nT(1) (**) = n + \Big(\frac{3}{4}\Big)n + \Big(\frac{3}{4}\Big)^2n + ... + 3^{\log_2 n} \cdot T(1) wiemy, że T(1)=Θ(1)T(1) = \Theta(1)
oraz alogbn=blogbalogbn=b(logbn)(logba)=nlogbaa^{\log_b n} = b^{\log_b a^{\log_b n}} = b^{(\log_b n) \cdot (\log_b a)} = n^{\log_b a} =n+(34)n+(34)2n+...+nlog43Θ(1) = n + \Big(\frac{3}{4}\Big)n + \Big(\frac{3}{4}\Big)^2 n + ... + n^{\log_4 3} \cdot \Theta(1) \le przy czym nαn^{\alpha} dla  α<1~\alpha < 1 nk=0(34)k+Θ(n2)=O(n) \le n\sum_{k=0}^{\infin}(\frac{3}{4})^k + \Theta(n^2) = \bold{O(n)}