common algorithms implemented by c