Algorithm, as its name suggests, is a method of calculation. Algorithms are usually used to solve specific computational tasks. Unlike programs that can run directly on a computer, algorithms are described mathematically and focus more on ideas; they can be regarded as abstract programs. The same algorithm can have many different implementations, and two different programs may use the same algorithm.
This chapter introduces some basic algorithms. When a computational task is sufficiently general and appears widely in various problems, algorithms that solve it are called by more algorithms and have considerable importance and foundational value. At the same time, the more general an algorithm is, the simpler it usually is, and the more closely it resembles an idea rather than a program. The algorithms introduced in this chapter are sufficiently elegant and interesting, and they often appear in later advanced content.