All implementations in this book are in C. C was chosen because it is still the most general-purpose language in use today. It is also one of the best languages in which to explore the details of data structures and algorithms while still working at a fairly high level. It may be helpful to note a few things about the code in this book.
There is also a focus on efficiency, but the primary purpose of all code is to teach the topic it addresses in a clear manner.
The platforms used for testing were HP-UX 10.20, SunOs 5.6, Red Hat Linux 5.1, and DOS/Windows NT/95/98. See the readme file on the accompanying website http://examples.oreilly.com/masteralgoc/) for additional information.
Every implementation includes a header that documents the public interface. Most headers are shown in this book. However, headers that contain only prototypes are not. (For instance, Example 12.1 includes sort.h, but this header is not shown because it contains only prototypes to various sorting functions.)
Static functions have file scope, so this fact is used to keep private functions private. Functions specific to a data structure or algorithm’s implementation are thus kept out of its public interface.
Defined constants appear entirely in uppercase. Datatypes and global variables begin with an uppercase character. Local variables begin with a lowercase character. Operations of abstract datatypes begin with the name of the type in lowercase, followed by an underscore, then the name of the operation in lowercase.
All comments are designed to let developers follow the logic of the code without reading much of the code itself. This is useful when trying to make connections between the code and explanations in the text.
The name of the structure is always the name in the typedef followed by an underscore. Naming the structure itself is necessary for self-referential structures like the one used for linked list elements (see Chapter 5). This approach is applied everywhere for consistency.
Although not required, this helps quickly identify where a void function returns rather than having to match up braces.