Understanding algorithms
In Chapter 1, we gave a definition of an algorithm and listed the essential properties. In this section, we will discuss how we go about verifying those properties and reasoning formally about an algorithm. This topic is, as you might suspect, an extensive field of study that is the subject of many books; Introduction to Algorithms by Cormen et al. is a classic book on the subject [1], and The Art of Computer Programming by Donald Knuth [2] is another. This section is intended to give just enough information to inform the rest of this chapter, and not a thorough treatment of the theory.
Recall from Chapter 1 that an algorithm must be finite, definite, effective, and have clear inputs and outputs. When developing new algorithms, the first thing one should check is correctness: does the algorithm actually deliver what it says it does? For this, one should ideally endeavor to prove mathematically that the algorithm is sound. For simple statements that don...