Data Structures and Algorithms beginning to talk about algorithm

First, what is an algorithm?

  1. Official explanation: algorithm describing solve a specific problem solution step, expressed as a finite sequence of instructions in a computer, and each represents one or more instruction operations.
  2. Simply put, the algorithm is that you do one thing or problem-solving skills and methods. For a given problem can be solved using a variety of algorithms. A problem can be solved by multiple algorithms, an algorithm has the ability but not the general solution to all problems.

Second, the characteristics of the algorithm

      1. Enter

  • Algorithm has zero or more input
  • Although for most algorithms, the input parameters are necessary. But sometimes, like print "Hello World!", You do not need any input parameters of.

      2. Output

  • Algorithm has at least one or more output.
  • Algorithm is sure to be output, the output does not need it, you want this algorithm to doing? The output form may be printed in the form of output, it may be a return value or multiple values ​​and the like.

      3. The finite nature

  • Algorithm means after performing a limited step is ended automatically without an infinite loop, and each step is completed within an acceptable time.

      4. Uncertainty

  • In each step algorithm has the meaning defined, it will not be ambiguous.
  • Algorithm Under certain conditions, only one execution path, the same input can have a unique output.

  • Each step of the algorithm should be precisely defined without ambiguity.

      5. Feasibility

  • Each step of the algorithm must be feasible, that is, each step can be completed by performing a limited number of times.

Third, the design requirements of the algorithm

      1. validity

  • Correctness of the algorithm means algorithm should at least have a demand input, output and processing unambiguous, correctly reflect the problem, can get the right answer.
  • Divided into the following four levels: (1) algorithm program no syntax errors. (2) program algorithm capable of generating legal input output meet the requirements. (3) algorithm program instructions capable of generating illegal input satisfy chaise. (4) For the algorithm program ornery test input has to meet output requirements.

      2. Readability

  • Another object of the algorithm is designed for ease of reading, understanding and communication.
  • The purpose of the code we write, on the one hand is to allow a computer to perform, but there is an important purpose of reading others to read and modify their own future.

      3. Robustness

  • When the input data is not legitimate, the algorithm can make a correlation process, rather than an exception, crashes or inexplicable results.

      4. The high efficiency and low storage time

  • Rapid program execution time, and the small footprint

 

This article is the original article, if there is a little bit of help to you, do not forget to point like oh! Than the heart! For reprint, please indicate the source, thank you!

 

Reproduced in: https: //my.oschina.net/aibinxiao/blog/1831816

Guess you like

Origin blog.csdn.net/weixin_34072857/article/details/92041135