algorithm and data structures code snippet in c