Implementation of various algorithms