algorithm
algorithmIt can be understood as a complete solution step composed of basic operations and prescribed operation sequence. Or it is regarded as a limited and exact calculation sequence designed according to the requirements, and such steps and sequences can solve a type of problem.
An algorithm is a finite sequence of several instructions that satisfy properties:
(1) Input: The quantity provided by the outside is used as the input of the algorithm.
(2) Output: The algorithm generates at least one quantity as output.
(3) Determinism: Each instruction that composes the algorithm is clear and unambiguous.
(4) Fiberty: The number of execution times of each instruction in the algorithm is limited, and the time for executing each instruction is also limited.
(5) Feasibility: All operations in the algorithm must be basic enough to make the executor or reader of the algorithm clear its meaning and how to execute it.
program
programIt is an ordered collection of computer instructions, an expression of algorithms in a certain programming language, and a specific implementation of algorithms on computers.
Differences and connections
(1) Algorithms generally use semi-formal language in description, while programs are described in formal computer language.
(2) Programs are an ordered collection of computer instructions.
(3) Programs do not all meet the characteristics required by the algorithm. For example, the operating system is a program executed in an infinite loop, so it is not an algorithm.
(4) An algorithm can write different programs in different programming languages.
(5) Algorithms are the steps to solve problems; programs are the code implementation of the algorithm.
(6) Algorithms need to rely on programs to complete functions; programs require algorithms as their souls.
(7) Program = algorithm + data structure.