The Algorithm Header File

The C++ standard library includes an algorithm header file. What you have seen throughout this chapter are algorithms that you wrote yourself. However, many algorithms are already done for you in the algorithm header file. Several of these algorithms are summarized in Table 13.1.

Table 13.1: The Algorithm Header File




A sorting algorithm.


This swaps elements.


Another sorting algorithm.

stable sort

Yet another sorting algorithm.

If you include the algorithm header file in your programs, you will have access to these and many other algorithms. It is still a good idea for beginning programmers to code their own sorting algorithms so that they develop a better understanding of how algorithms work.

The list in Table 13.1 is, by no means, exhaustive. It is, rather, meant as a sample of the algorithms already worked out for you. The key point to remember is that many algorithms are already worked out for you and ready for you to implement. You merely need to include the algorithm header file and appropriately call these algorithms.

click to expand
Figure 13.5: The quick sort.

C++ Programming Fundamentals
C++ Programming Fundamentals (Cyberrookies)
ISBN: 1584502371
EAN: 2147483647
Year: 2005
Pages: 197
Authors: Chuck Easttom © 2008-2017.
If you may any questions please contact us: