By means of the substitution method for recurrences, a lower limit or upper limit of the (computational) effort of a recursion can be determined.
Describe the method
A recursion T (n) of the form T (n) = a⋅T (n / b) + f (n) is given. In order to determine an upper bound, it is first estimated using the Ο-calculus . Estimating means “clever guessing”. The presumption is then proven or disproved with the help of substitution. The procedure for determining the lower limit is analogous.
Assumption (1) : T (n) ≤ c⋅g (n), with c> 0 or T (n) ∈ Ο (g (n)) (according to the definition of the Ο-calculus)
Assumption (2) : T sub (n / b) ≤ c⋅g (n / b)
Substitution by inserting the assumption into the recurrence: T (n) ≤ a⋅T sub (n / b) + f (n) or T (n) ≤ a⋅ (c⋅g (n / b)) + f ( n)
Exact (3) conversion to: T (n) ≤ c⋅g (n) → If this is not possible, either the conjecture or the assumption (2) was wrong.
Proof of T (n) ≤ c⋅g (n) by induction ⇒ T (n) ∈ Ο (g (n))
(1)
The conjecture is the bound estimated upwards, so that: T (n) ≤ c⋅g (n) ∈Ο (g (n))
(2)
If at 4. T (n) cannot be transformed exactly (3) , one can subtract a term t (n) of lower order from the assumption T sub (n / b) ≤ c⋅g (n / b) . The new assumption is then: T sub (n / b) ≤ c⋅g (n / b) - t (n)
(3)
This means that z. B. T (n) ≤ (c + 1) ⋅g (n) is not the exact form of the conjecture. For example, T (n) ≤ c⋅g (n) or T (n) ≤ (c-1) ⋅g (n) would be correct.
example
Example (1) :
1st assumption:
2. Assumption: and
3. Substitution:
4. Forming:
With
5. Induction:
IA: with
IV: for
IS: n → n + 1: Since it has been shown for an n 0 that T (n) ≤ c⋅n⋅ln (n) is correct, the conjecture is correct. (It turns out that a constant c ≥ 1.443 is sufficient.)
Hence for T (n) it follows:
Example (2) :
For the same example, see also the effort estimation with the Kalk-calculus in the article on the master theorem .
1st assumption:
2. Assumption: with and
3. Substitution:
4. Forming:
With
5. Induction:
IA: with
IV: for
IS: n → n + 1: Since it has been shown for an n 0 that T (n) ≤ c⋅n 3 ln 2 (n) is correct and that c can be a constant of any size, the conjecture is correct. (A constant c ≥ 4 is sufficiently large for all n.)