Skip to content

Commit

Permalink
#118 apply the master method more precisely
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtask committed Apr 3, 2024
1 parent 9d73813 commit 4d86c08
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion chapter4/sections/1/3.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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)$.
6 changes: 4 additions & 2 deletions chapter4/sections/2/3.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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})$.

0 comments on commit 4d86c08

Please sign in to comment.