Implementation of a few algorithms