O'Reilly logo

Learn C the Hard Way: A Clear & Direct Introduction To Modern C Programming by Zed A. Shaw

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Exercise 33. Linked List Algorithms

Im going to cover two algorithms for a linked list that involve sorting. I’m going to warn you first that if you need to sort the data, then don’t use a linked list. These are horrible for sorting things, and there are much better data structures you can use if that’s a requirement. I’m covering these two algorithms because they are slightly difficult to pull off with a linked list, and to get you thinking about how to efficiently manipulate them.

In the interest of writing this book, I’m going to put the algorithms in two different files list_algos.h and list_algos.c then write a test in list_algos_test.c. For now, just follow my structure, since it keeps things clean, but if you ever work on other libraries, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required