next up previous
Next: Appendix: Mathematical symbol glossary Up: No Title Previous: Big-O and notation

Recurrence Formulae

When analysing algorithms one will often end up with a proof by induction that shows that the method described does indeed always solve the problem it was supposed to. Quite frequently this proof can be extended to yield a way of estimating the costs involved. Look back to the Tower of Hanoi example, and now we know that given a tower of n discs it can be moved from one peg to another, consider how many elementary moves will be used if we follow the recipe implicit in the inductive proof. To do this start by introducing a name for the cost, say M(n) for the number of steps to move n discs. Then from the base case of the induction we have M(1) = 1. The induction step shows that success is possible by a route which gives

M(n) = M(n-1) + 1 + M(n-1) = 2M(n-1) + 1

This is a recurrence formula that we would like to solve to find some explicit representation of the cost growth function M(n). Note that the proof we have does not show that this will necessarily be the most efficient way of moving the discs, just that it is one way that achieves the desired final configuration. Thus any result we get out from solving the recurrence will probably be put inside a Big-O to indicate that it is just an upper bound for the cost of solving the problem.

This course will not have either the time or inclination to show you all the clever ways there are of solving recurrence formula, and instead just provides a cook-book listing some of the more commonly arising ones and indicating their solutions. Symbols with names like k stand for constants, and will sometimes need to have values larger than 0 or 1 for the results quoted to be valid.

f(n) = f(n-1) + k &:& f(n) = \Theta(n k) \...
f(n) = f(n-1) + f(n-2) &:& f(n) = \Theta(\phi^{n})

where $\phi = (\sqrt{5}+1)/2 \approx 1.618034$, the golden ratio. In each case more careful analysis would specify the exact constraints on the values of the constants permitted, and limitations on the initial values of f(0) or f(1). Often an exact solution (not just one correct to within the constant factor that $\Theta$ permits) can be found, for instance for the Hanoi problem the solution is M(n) = 2n-1.

next up previous
Next: Appendix: Mathematical symbol glossary Up: No Title Previous: Big-O and notation
Alan Mycroft