Outline of algorithm.