Traditional Culture Encyclopedia - Traditional culture - What are the methods of representing algorithms

What are the methods of representing algorithms

The representations of algorithms are: natural language, traditional flowcharts, pseudo-code, structured flowcharts (N_S flowcharts, box diagrams).

1. Natural Language Description of Algorithms

It is a way of describing algorithms, which expresses the process of running the algorithm and the results through natural language. Although describing algorithms in natural language is more intuitive and easy to understand, it lacks intuition and conciseness and is prone to ambiguity. This way of description is suitable for scenarios that require precise description of the algorithm's logic and running process, but in everyday use, ordinary programmers are usually more accustomed to using natural language to describe algorithms rather than directly using computer programs to describe them.

2, traditional flowchart

Traditional flowchart is a method of algorithm representation, which connects the block diagrams with a flow line to indicate the execution order of the algorithm. Through the flow line can clearly show the execution order of the algorithm, it is convenient for us to understand and describe the execution process of the algorithm.

3, pseudo-code

Pseudo-code is a kind of algorithm description between natural language and computer language, without strict syntax restrictions. Pseudo-code usually does not contain specific language structures and syntax rules, but uses simple and easy to understand keywords and symbols to express. For example, "if" means conditional judgment, "for" means loop and so on. Pseudo-code is a tool to express some ideas during the execution of an algorithm, not to execute the code itself.

An algorithm is an accurate and complete description of a solution, a clear set of instructions for solving a problem, and an algorithm represents a systematic way of describing a strategic mechanism for solving a problem. That is to say, the ability to obtain the required output in a limited time for a certain specification of input.

If an algorithm is flawed or unsuitable for a problem, executing it will not solve the problem. Different algorithms may accomplish the same task in different amounts of time, space, or efficiency. The strength of an algorithm can be measured in terms of space complexity versus time complexity.

An instruction in an algorithm describes a computation that, when run, can start from an initial state and (possibly empty) initial inputs, go through a finite and well-defined set of states, and ultimately produce an output and stop in a final state. The transfer from one state to another is not necessarily deterministic. Some algorithms, including randomized algorithms, contain some random inputs.