basic algorithms implmentations in python