Implement algorithms in python