Daniel Sutantyo, Department of Computing, Macquarie University
6.3 - Master Method
6.3 - Master Method
Given a recurrence of the form
\(T(n) = aT(n/b) + f(n) \)
6.3 - Master Method
\(T(n) = aT(n/b) + f(n) \)
\(f(n) = O(n^{\log_b a-\varepsilon})\)
\(f(n) = \Theta(n^{\log_b a})\)
\(f(n) = \Omega(n^{\log_b a + \varepsilon})\)
\(T(n) = aT(n/b) + cn^k \)
\(T(n) = \Theta(n^{\log_ba})\)
\(T(n) = \Theta(n^{\log_ba}\log n)\)
\(T(n) = \Theta({f(n)})\)
6.3 - Master Method
\(T(n) = aT(n/b) + f(n) \)
\(T(n) = aT(n/b) + cn^k \)
\(T(n) = \Theta(n^{\log_ba})\)
\(f(n) = O(n^{\log_b a-\varepsilon})\)
for some constant \(\varepsilon>0\)
\( b^k = a / b^\varepsilon\)
\( b^k < a \)
6.3 - Master Method
\(T(n) = aT(n/b) + cn^k \)
\(T(n) = \Theta(n^{\log_ba})\)
\( b^k < a \)
and
then
6.3 - Master Method
\(T(n) = aT(n/b) + cn^k \)
\(T(n) = \Theta(n^{\log_ba})\)
\( b^k < a \)
and
then
\(T(n) = \begin{cases} \Theta(1) &\text{if $n \le 1$}\\ 2T(n/2) + \Theta(1)&\text{otherwise} \end{cases}\)
\(a = 2\)
\(b = 2\)
\(k = 0\)
is \( b^k < a \)?
so \(T(n) = \Theta(n^{\log_2 2}) = \Theta(n)\)
6.3 - Master Method
\(T(n) = aT(n/b) + cn^k \)
\(T(n) = \Theta(n^{\log_ba})\)
\( b^k < a \)
and
then
\(T(n) = \begin{cases} \Theta(1) &\text{if $n \le 1$}\\ 3T(n/3) + \Theta(1)&\text{otherwise} \end{cases}\)
\(a = 3\)
\(b = 3\)
\(k = 0\)
is \( b^k < a \)?
so \(T(n) = \Theta(n^{\log_3 3}) = \Theta(n)\)
6.3 - Master Method
\(T(n) = aT(n/b) + cn^k \)
\(T(n) = \Theta(n^{\log_ba})\)
\( b^k < a \)
and
then
\(T(n) = \Theta(n^{\log_ba}\log n)\)
\(T(n) = \Theta(n^k)\)
\(T(n) = aT(n/b) + cn^k \)
\( b^k = a \)
and
then
\(T(n) = aT(n/b) + cn^k \)
\( b^k > a \)
and
then
6.3 - Master Method
\[T(n)=\begin{cases}\Theta(n^{\log_b a}),&\text{if $f(n) = O(n^{\log_b a - \epsilon})$ for $\epsilon > 0$}\\\Theta(n^{\log_ba}\log n),&\text{if $f(n)=\Theta(n^{\log_b a})$}\\\Theta(f(n)),&\text{if $f(n) = \Omega(n^{\log_ba+\epsilon})$ for $\epsilon > 0$}\end{cases}\]
\[T(n)=\begin{cases}\Theta(n^{\log_ba}),&\text{if $a > b^k$ }\\\Theta(n^{\log_ba}\log n),&\text{if $a = b^k$}\\\Theta(n^k),&\text{if $a < b^k$}\end{cases}\]
\[T(n) = aT(n/b) + cn^k \]
6.3 - Master Method
\(T(n) = aT(n/b) + cn^k \)
\(T(n) = \Theta(n^{\log_ba})\)
\( b^k < a \)
and
then
\(T(n) = \Theta(n^{\log_ba}\log n)\)
\(T(n) = \Theta(n^k)\)
\(T(n) = aT(n/b) + cn^k \)
\( b^k = a \)
and
then
\(T(n) = aT(n/b) + cn^k \)
\( b^k > a \)
and
then
6.3 - Master Method
\(T(n) = aT(n/b) + cn^k \)
\(T(n) = \Theta(n^{\log_ba})\)
\( b^k < a \)
and
then
\(T(n) = \Theta(n^{\log_ba}\log n)\)
\(T(n) = \Theta(n^k)\)
\(T(n) = aT(n/b) + cn^k \)
\( b^k = a \)
and
then
\(T(n) = aT(n/b) + cn^k \)
\( b^k > a \)
and
then
\(T(n) = \begin{cases} \Theta(1) &\text{if $n \le 1$}\\ 2T(n/2) + \Theta(n)&\text{otherwise} \end{cases}\)
6.3 - Master Method
\(T(n) = aT(n/b) + cn^k \)
\(T(n) = \Theta(n^{\log_ba})\)
\( b^k < a \)
and
then
\(T(n) = \Theta(n^{\log_ba}\log n)\)
\(T(n) = \Theta(n^k)\)
\(T(n) = aT(n/b) + cn^k \)
\( b^k = a \)
and
then
\(T(n) = aT(n/b) + cn^k \)
\( b^k > a \)
and
then
\(T(n) = \begin{cases} \Theta(1) &\text{if $n \le 1$}\\ 2T(n/2) + \Theta(n)&\text{otherwise} \end{cases}\)
\(a = 2\)
\(b = 2\)
\(k = 1\)
\( b^k = a \)?
so \(T(n) = \Theta(n^{\log_2 2}\log n) = \Theta(n\log n)\)
6.3 - Master Method
\(T(n) = aT(n/b) + cn^k \)
\(T(n) = \Theta(n^{\log_ba})\)
\( b^k < a \)
and
then
\(T(n) = \Theta(n^{\log_ba}\log n)\)
\(T(n) = \Theta(n^k)\)
\(T(n) = aT(n/b) + cn^k \)
\( b^k = a \)
and
then
\(T(n) = aT(n/b) + cn^k \)
\( b^k > a \)
and
then
\(T(n) = \begin{cases} \Theta(1) &\text{if $n \le 1$}\\ 3T(n/4) + cn^2 &\text{otherwise} \end{cases}\)
6.3 - Master Method
\(T(n) = aT(n/b) + cn^k \)
\(T(n) = \Theta(n^{\log_ba})\)
\( b^k < a \)
and
then
\(T(n) = \Theta(n^{\log_ba}\log n)\)
\(T(n) = \Theta(n^k)\)
\(T(n) = aT(n/b) + cn^k \)
\( b^k = a \)
and
then
\(T(n) = aT(n/b) + cn^k \)
\( b^k > a \)
and
then
\(T(n) = \begin{cases} \Theta(1) &\text{if $n \le 1$}\\ 3T(n/4) + cn^2 &\text{otherwise} \end{cases}\)
\(a = 3\)
\(b = 4\)
\(k = 2\)
\( b^k > a \)?
so \(T(n) = \Theta(n^2)\)
6.3 - Master Method