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, ...

Get Learn C the Hard Way: A Clear & Direct Introduction To Modern C Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.