Algorithms implemented in c