If a problem of size n is divided into a problems each of size n/c, and it takes bn work to bring together the solutions of the subproblems, then
| T(n) = aT(n/c) + bn, | when n > 1 | |
| T(n) = b, | when n = 1 |
For real problems, a,b,c are non-negative. In this case, when n is a power of c, we have...
| T(n) = Θ( n ) , | when a < c | |
| T(n) = Θ( n log n ) , | when a = c | |
| T(n) = Θ( nlogca ), | when a > c |
T(n) =
aT(n/c) + bn
= a[aT(n/c2)
+ b(n/c)] + bn
= a2T(n/c2)
+ bn[1 + a/c]
= a2[aT(n/c3)
+ b(n/c2)]
+ bn[1 + a/c]
= a3T(n/c3)
+ bn[1 + a/c + (a/c)2]
. . .
= amT(n/cm)
+ bn[1 + a/c + (a/c)2
+ ... + (a/c)m-1]
( Note that T(1) = b and that amb
= amb(n/cm)
= bn(a/c)m. )
= bn[1 + a/c + (a/c)2
+ ... + (a/c)m].
Therefore, T(n) = bn ∑i = 0 to logcn (a/c)i.
Thus, T(n) = O(am).
Also, from above we have that
T(n) = Ω(am).
Therefore,
T(n) = Θ(am).
Since am = alogcn = nlogca, we conclude that T(n) = Θ( nlogca ).
Proof.
Let n = r cm,
for 1 < r < c.
Then T(n)
≤ T(cm+1)
≤ a(cm+1)k
= a((c/r)n)k
= a(c/r)knk
Finally, note that
b = a(c/r)k
is a constant.
If T(n) = aT(n/b) + f(n),
where a ≥ 1, b > 1,
f(n) asymptotically > 0,
and n/b means either the floor or ceiling of (n/b)
then T(n) =
| Θ( nlogba ), | when f(n) = O ( nlogba-ε ) | |
| Θ( nlogba logk+1n ), | when f(n) = Θ( nlogba logkn ), for k ≥ 0 | |
| Θ( f(n) ), | when f(n) = Ω( nlogba+ε )
and af(n/b) ≤ cf(n), for some c < 1, for all n > n0 |