The algorithm refers to the accurate and complete description of the solution to the problem. is a set of rules that rigorously define the order of operations, and each rule is valid and unambiguous, without ambiguity, and the rule will be terminated after a finite number of operations.
1) basic features of the algorithm
(1) Feasibility: Because the design of the algorithm is designed to solve a certain practical problem on a particular computing tool.
(2) Certainty: The design of the algorithm must be a clear definition of each step, do not allow a vague interpretation, there can be no ambiguity.
(3) There is poor sex: The algorithm is poor, that is, in a certain time is able to complete, that the algorithm should be calculated after a limited number of steps to the normal end.
(4) have enough intelligence: the execution of the algorithm is related to the input data and the provided initial conditions, different input or initial conditions will have different output results, provide accurate initial conditions and data, in order to make the algorithm correctly executed.
2) Basic elements of the algorithm
One is the operation and manipulation of the data object, and the other is the control structure of the algorithm.
(1) Calculation and operation of data in the algorithm
The algorithm is actually a set of sequences of instructions that are composed of the appropriate actions to be chosen from all the operations that the environment can perform in order to solve the problem. That is, an algorithm is a sequence of instructions that a computer can manipulate.
(2) control structure of the algorithm
In the algorithm, the execution order of the operation is called the control structure of the algorithm, the general algorithm control structure has three kinds: the sequential structure, the choice structure and the cyclic structure.
3) Basic method of algorithm design
(1) enumeration: The basic idea is to enumerate all possible situations according to the questions raised, and to test which conditions are satisfied and which are not satisfied by the condition given in the question.
(2) Inductive method: The basic idea is, by enumerating a small number of special cases, after analysis, finally find out the general relationship.
(3) Recursion: Starting from the known initial conditions, each successive introduction of the required intermediate and final results. Nature is also a kind of induction, recursive relationship is usually the result of induction.
(4) Recursion: in solving some complex problems, in order to reduce the complexity of the problem of the program, usually the problem is divided into layers, and finally boils down to some of the simplest problems. It is divided into two methods: direct recursion and indirect recursion.
(5) Halve recursion technology: Halve the size of the problem by half, and then repeat the same recursive action.
(6) Backtracking: Some practical problems can not be summed up a simple set of recursive formulas or intuitive solution steps, nor can you use infinite enumeration.
Basic concepts of algorithms