19

I have been reading Introduction to Algorithms by Cormen et al. and I'm reading the statement of the Master theorem starting on page 73. In case 3 there is also a regularity condition that needs to be satisfied to use the theorem:

... 3. If

$\qquad \displaystyle f(n) = \Omega(n^{\log_b a + \varepsilon})$

for some constant $\varepsilon > 0$ and if

$\qquad \displaystyle af(n/b) \leq cf(n)$      [this is the regularity condition]

for some constant $c < 1$ and for all sufficiently large $n$, then ..

Can someone tell me why the regularity condition is needed? How does the theorem fail if the condition is not satisfied?

3 Answers3

13

Not a rigorous proof, but a "from the top of my head" explanation.

Imagine the recurrence $aT(n/b)+f(n)$ as a tree. The third case covers the scenario when the root node dominates the running time asymptotically, i.e. most of the work is being done in measly node on top of the recurrence tree. Then the running time is $\Theta(f(n))$.

To make sure the root actually does more work you need the

$a f(n/b) \leq cf(n)$.

This says that $f(n)$ (the amount of work done in the root) needs to be at least as big as the sum of the work done in the lower levels. (The recurrence is called $a$ times on $n/b$ of the input.)

E.g. for the recurrence $T(n)=2T(n/4)+n$ the work on the level below the root is one fourth as big and only done twice $(n/4+n/4)$ versus $n$ so the root dominates.

But what if the function didn't fulfill the regularity condition? E.g. $\cos(n)$ instead of $n$? Then the work done on the lower levels might be bigger than the work done in the root so you are not certain that the root dominates.

The Unfun Cat
  • 1,803
  • 2
  • 19
  • 29
9

Let $a = 1$ and $b = 2$, so that $$ T(2^n) = \sum_{k=0}^n f(2^k). $$ For case 3 to apply, we need $f(n) = \Omega(n^\epsilon)$ (for some $\epsilon > 0$) and the regularity condition, $f(n/2) \leq (1-\delta) f(n)$ (for some $\delta > 0$). You get the regularity condition from the proof, i.e. it's a proof-generated concept. While the regularity condition isn't necessary (consider the example given on Wikipedia, $f(n) = n(2-\cos n)$), you can't drop it completely, as the following example demonstrates. Consider $$f(2^n) = 2^{2^{\lfloor \log_2 n \rfloor}} > 2^{2^{\log_2n-1}} = 2^{n/2}.$$ Let $n = 2^{m+1}-1$. Then $$T(2^n) = \sum_{k=0}^m \sum_{t=2^k}^{2^{k+1}-1} 2^{2^k} = \sum_{k=0}^m 2^{2^k+k} = \Theta(2^{2^m+m}), \quad f(2^n) = 2^{2^m}. $$ So it's not true that $T(2^n) = \Theta(f(2^n))$.

There is a more general theorem, Akra-Bazzi, in which the regularity condition is replaced by an explicit quantity that comes into the result.

Yuval Filmus
  • 280,205
  • 27
  • 317
  • 514
-1

We check regularity condition to check whether the work done by parents node is more than the work done by children. If the regularity condition fail we use another method in recurrences.

xskxzr
  • 7,613
  • 5
  • 24
  • 47