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.
Algorithm | Description |
---|---|
partial_sort | A sorting algorithm. |
swap | This swaps elements. |
sort | 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.
Figure 13.5: The quick sort.