Implementation of some algorithms