implementation of algorithms in python