Implementation of various algorithms.