-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,22 @@ | ||
\workinprogress % TODO | ||
We'll instead consider the recurrence $T(n)=4T(n/2)+\Theta(n)$, of which the original recurrence is a special case, and we'll show that $T(n)=O(n^2)$. | ||
|
||
Our first guess is that $T(n)\le cn^2$ for all $n\ge n_0$, where $c$, $n_0>0$ are constants. | ||
Letting $n\ge2n_0$ and substituting the inductive hypothesis applied to $T(n/2)$, yields | ||
\begin{align*} | ||
T(n) &\le 4c(n/2)^2+\Theta(n) \\ | ||
&= cn^2+\Theta(n), | ||
\end{align*} | ||
but that does not imply that $T(n)\le cn^2$ for any choice of $c$ and for any function represented by the $\Theta(n)$ term. | ||
|
||
Let's then improve our guess by subtracting a lower-order term: $T(n)\le cn^2-dn$, where $d\ge0$ is another constant. | ||
Assuming that $T(n/2)\le c(n/2)^2-d(n/2)$, we now have | ||
\begin{align*} | ||
T(n) &\le 4(c(n/2)^2-d(n/2))+\Theta(n) \\ | ||
&= cn^2-2dn+\Theta(n) \\ | ||
&= cn^2-dn-(dn-\Theta(n)) \\ | ||
&\le cn^2-dn, | ||
\end{align*} | ||
where the last step holds as long as for $n\ge2n_0$ the quantity $dn$ dominates the anonymous function hidden by the $\Theta(n)$ term. | ||
|
||
Let's pick $n_0=1$. | ||
By choosing a sufficiently large $c$, we can satisfy the condition $T(1)\le c\cdot1^2-d\cdot1$ for any fixed constants $d$ and $T(1)$, so the bound also holds when $n_0\le n<2n_0$. |