Algorithm and data structures in C