Section 414, Python commonly used algorithm learning

Contents of this section

  1. Algorithm Definition
  2. time complexity
  3. space complexity
  4. Common algorithm examples

1. Algorithm Definition 

Algorithm refers to an accurate and complete description of a problem-solving scheme, and is a series of clear instructions for solving problems. Algorithms represent a systematic method to describe the strategy mechanism for solving problems. That is to say, the required output can be obtained in a limited time for a certain specification of input. If an algorithm is flawed, or not suitable for a problem, executing the algorithm will not solve the problem. Different algorithms may accomplish the same task with different time, space or efficiency. The pros and cons of an algorithm can be measured by space complexity and time complexity.

An algorithm should have the following seven important characteristics:

①Finiteness: The finiteness of an algorithm means that the algorithm must be able to terminate after executing a finite number of steps;

②Definiteness: Each step of the algorithm must have a precise definition;

③Input: An algorithm has 0 or more inputs to describe the initial situation of the operation object. The so-called 0 input means that the algorithm itself defines the initial conditions;

④ Output: An algorithm has one or more outputs to reflect the result of processing the input data. Algorithms without outputs are meaningless;

⑤Effectiveness: Any calculation step performed in the algorithm can be decomposed into basic executable operation steps, that is, each calculation step can be completed in a limited time (also called effectiveness);

⑥High efficiency: fast execution speed and low resource consumption;

⑦ Robustness (Robustness): correct response to data.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324740816&siteId=291194637