An algorithm is defined as a finite sequence of unambiguous instructions for solving a problem.

  • Every algorithm requires an input
  • The output depends only on the input
  • The algorithm must terminate in a finite time for all inputs (it doesn't get stuck in a loop)


The order of an algorithm is a measure of the approximate run time for an algorithm, depending on the size of the problem. For large problems we only need to consider the dominant term to get an approximate run time.

The efficiency of an algorithm is a measure of how well an algorithm copes with an increase in the size, n, of a problem. The efficiency decreases as run time increases.

Order Run time proportional to
Linear n
Quadratic n^2
Cubic n^3
Exponential x^n or n!


A computer takes 2 seconds to solve a problem of size 30. Estimate the times taken to solve a problem of size 300 if the algorithm used has

  • an order n

 2 \times \frac = 20\ seconds

  • an order n2

 2 \times (\frac)^2 = 200\ seconds \approx 3.33\ minutes

  • an order n3

 2 \times (\frac)^3 = 2000\ seconds \approx 33.3\ minutes

  • an order 2n

 time \propto 2^n

 t = k \times 2^n

 2 = k \times 2^

 k = \frac}

Therefore, using n = 300

t = 2^ \times \frac}

t \approx 3.79e81\ seconds \approx 1.2e71\ millenia