Recurrence relations are a mathematical sequence describing how a recurring algorithm divides/decreases the work done. Conventionally, is used to denote the work done for input size .

Most recurrence relations that use Divide-and-Conquer as a design pattern can be solved with the Master Theorem.

Formula

If where

  • = The amount of subproblems that are used by the algorithm.
  • = The factor by which the n problem is divided into.
  • = The polynomial factor of n, the additional work done by the algorithm then:

For example, take the example of a divide-and-conquer algorithm, mergesort. The recursion tree of mergesort is as follows:

Link to source

There are 2 ways to solve general recurrence relations to obtain a closed-form formula:

  • Iteration
  • Telescoping

Iteration

Iteration involves by building the relation from the bottom-up, by substituting small values of n.

For example:

Telescoping

Telescoping involves rearranging the equation and cancelling out terms

For example: