Implementation of some algorithms in python