implement some common algorithms in python for easy use