The main theorem of runtime functions - or often borrowed from English as a master theorem - is a special case of the Akra-Bazzi theorem and offers a quick solution to the question of which runtime class a given recursively defined function is in. However, not every recursively defined function can be solved with the master theorem. If none of the three possible cases of the master theorem can be applied to the function T, then the complexity class of the function has to be calculated in another way.
Here stands for the runtime function you are looking for, while and are constants. Furthermore denotes an independent and non-negative function. In order for the master theorem to be applicable, the conditions and must be fulfilled for the two constants .
Interpretation of the recursion for :
= Number of sub-problems in the recursion
= Part of the original problem, which in turn is represented by all sub-problems
= Costs (effort, ancillary costs) that arise from dividing the problem and combining the partial solutions
The master theorem distinguishes three cases, whereby at most one case can be applied to the given recursion. If none of the cases fit, the master theorem cannot be applied and other methods have to be used.
First case
Second case
Third case
General
If:
for a
for a
and also for one with and all sufficiently large applies:
Then follows:
example
The following can be read from the formula:
,
,
,
1st condition:
for a
for a
Insert values:
Choose :
with ✔
✔
with ✔
2nd condition: (only in the 3rd case)
Use the above values here as well:
Choose c = ½:
✔
The following applies to the runtime function:
( ✔ = true statement)
Generalization of the second case
Not all recurrence equations can be solved using one of the three cases of the master theorem. For example, the following recurrence equation cannot be solved directly with the master theorem.
.
At first glance it seems that the 3rd case applies:
There is none , so the limit is not zero. So the 3rd case is not applicable to this recursion equation!
The following applies: if
If you look closely, this formula is a generalization of the second case.
Solution according to the above formula:
✔
Since the sufficient condition is met, the following applies:
For the same example, see also the effort estimate in the Ο-calculus with the help of the substitution method .
Remarks
Assume that the following recurrence is given, for which the floor or ceiling function is used:
z. B .:
In this case one can estimate or with the help of the shape .
It doesn't matter whether you write (natural logarithm) or (decadic logarithm), since according to the logarithm laws:
More general form
In a more general form, the following also applies:
definition
Let be the mapping of the shape to be examined
,
where , and with .
is continued implicitly through or for on the real numbers.
Then:
literature
Thomas H Cormen, Charles E. Leiserson , Ronald L. Rivest , Clifford Stein: Algorithms - An Introduction . Oldenbourg, Munich, Vienna 2004, ISBN 3-486-27515-1 (Original title: Introduction to algorithms . Translated by Karen Lippert, Micaela Krieger-Hauwede).