In mathematics and computer science, algorithm is a clear specification of how to solve a class of problems. Algorithms can perform calculations, data processing, automatic reasoning and other tasks.
As an effective method, the algorithm can express the calculation function in a well-defined formal language in a limited space and time. Starting from an initial state and an initial input (which may be empty), an instruction describes a calculation that, when executed, goes through a limited number of clearly defined continuous states, and finally produces an "output" and ends in a final ending state. The transition from one state to the next is not necessarily clear; Some algorithms called random algorithms contain random inputs.