Implementation of some common algorithms