code for some popular algorithms