algorithms implemented in c