From 4d86c083b83bae7af6d66b5f641225ebfed43ee7 Mon Sep 17 00:00:00 2001 From: Krzysztof Wojtas Date: Thu, 4 Apr 2024 00:24:49 +0200 Subject: [PATCH] #118 apply the master method more precisely --- chapter4/sections/1/3.tex | 2 +- chapter4/sections/2/3.tex | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/chapter4/sections/1/3.tex b/chapter4/sections/1/3.tex index 5a672ba..e140c59 100644 --- a/chapter4/sections/1/3.tex +++ b/chapter4/sections/1/3.tex @@ -4,4 +4,4 @@ \] To show it has the same solution as the original recurrence, let's use the master method from Section 4.5. The above is a master recurrence with $a=8$, $b=2$, and driving function $f(n)=\Theta(n^2)$. -Since $n^{\log_ba}=n^{\lg8}=n^3$ and $f(n)=O(n^{3-\epsilon})$ for any $\epsilon\le1$, we can apply case~1 of the master theorem to get $T(n)=\Theta(n^3)$. +Since $n^{\log_ba}=n^{\lg8}=n^3$ and $f(n)=O(n^{3-\epsilon})$ for any $0<\epsilon\le1$, we can apply case~1 of the master theorem to get $T(n)=\Theta(n^3)$. diff --git a/chapter4/sections/2/3.tex b/chapter4/sections/2/3.tex index 5eb658b..0f3fa93 100644 --- a/chapter4/sections/2/3.tex +++ b/chapter4/sections/2/3.tex @@ -6,8 +6,10 @@ Let $T(n)$ be the worst-case time to multiply two $n\times n$ matrices by this algorithm. If we did the partitioning using index calculations, then we get the recurrence \[ - T(n) = kT(n/3)+\Theta(1) + T(n) = kT(n/3)+\Theta(1). \] -which, by the master method, has the solution $T(n)=\Theta(n^{\log_3k})$. +To solve it, we'll use the master method. +We have $a=k$, $b=3$, and driving function $f(n)=\Theta(1)$. +Since $n^{\log_ba}=n^{\log_3k}$ and $f(n)=O(n^{\log_3k-\epsilon})$ for $0<\epsilon\le\log_3k$, we apply case~1 of the master theorem to get $T(n)=\Theta(n^{\log_3k})$. According to \refProblem{3-1}(d), $T(n)=o(n^{\lg7})$ if $\log_3k<\lg7$, which gives us $k<3^{\lg7}\approx21.85$. Hence, the largest integer value for $k$ is 21 and then the running time of the algorithm is $T(n)=\Theta(n^{\log_321})=O(n^{2.78})$.