Flowchart related Specifications

Source: Internet
Author: User

The flowchart of the relevant algorithm in this paper is shown.
In the flowchart, the process line on the left of the judging box indicates the process that the condition is true, and the process line on the right represents the process when the condition is false, and sometimes it is labeled "true", "false" or "T", "F" or "Y", "N" on the top of its left and right process lines.

It is also stipulated that the process line is from bottom to top or right-to-left, must have an arrow, in addition, do not draw arrows, flow line direction always from top to bottom or from left to right.

Structured description of the algorithm
Early unstructured languages have go to statements that allow programs to jump directly from one place to another. The advantage of doing this is that the program design is very convenient and flexible, reduce the artificial complexity, but its shortcomings are very prominent, a large pile of jump statements make the process of the program is very complex disorder, difficult to understand and difficult to verify the correctness of the program, if wrong, it is very difficult to queue up. The confusion and complexity of this revolving flowchart is a vivid portrayal of the situation of the program personnel in the software crisis. and structured programming, is to mess this group of clear.
After research, it is found that any complex algorithm can be composed of three basic structures of sequential structure, choice (branch) structure and cyclic structure, so when we construct an algorithm, we only take these three basic structures as "building units", abide by the specification of three basic structures, and the basic structure can be tied and Can be included, but not crossed, and not allowed to go directly from one structure to the inside of another. Just because the whole algorithm is composed of three basic structures, like building with modules, so the structure is clear, easy to verify the correctness, easy to correct, this method is a structured approach. The program design that follows this method is structured programming.
Accordingly, as long as the flow chart of the three basic structure is specified, the flowchart of any algorithm can be drawn.
(1) Sequential structure
The sequential structure is a simple linear structure in which the boxes are executed sequentially. The basic form of its flowchart is shown in 1-4, and the order of execution of the statement is: A→b→c.
(2) Select (branch) structure
This structure is a given condition to be judged, the condition is true or false when the contents of different boxes are executed separately. There are two basic shapes, 1-5 a), b) shown. The execution sequence of Figure 1-5 a) is: Execute a When the condition is true, otherwise execute B; Figure 1-5 B) executes a sequence of: When a condition is true, do nothing.

(3) Cycle structure
There are two basic forms of the cyclic structure: the while loop and the Do-while loop.
A. While-loop
As shown in 1-6. Its execution sequence is: When the condition is true, repeatedly executes a, once the condition is false, jumps out of the loop, executes the loop tight statement.
B. Do-while type cycle
As shown in 1-7.

The execution sequence is: First execute a, then judge the condition, the condition is true, always loop to execute a, once the condition is false, end the loop, execute the next statement after Loop tight.
In Figure 1-6, figure 1-7, A is called the loop body, the condition is called the cyclic control condition. It is important to note that:
1) in the loop body, it is necessary to modify the value of the condition to judge, so that after the finite cycle, the cycle must be able to end, 1-3 i = i-1.
2) The loop body may not be executed once in a loop, and the loop body is executed at least once for the type loop.
3) until the type cycle can be easily converted into a type of cycle, and when the loop does not necessarily translate into a loop. For example, figure 1-7 can be converted to figure 1-8.

N-S Diagram description algorithm
The N-S diagram is another algorithm representation, which is by the Americans I. Nassi and B.shneiderman co-proposed, its basis is: since any of the algorithms are described in the previous three structure, so the process line between the basic structure is redundant, therefore, the N-S diagram is also a structured description of the algorithm. In the N-S diagram, an algorithm is a large rectangular box containing a number of basic boxes, three basic structure of the N-S diagram is described as follows:
1. Sequential structure
1-9, the execution sequence is preceded by a B.
2. Select structure
The n-S diagram corresponding to Figure 1-5 is figure 1-1 0. Figure 1-10 A) executes a when the condition is true, and the condition is false when B is executed. Figure 1-10 B The condition is true when you execute a, and do nothing at the time of the false.

3. Cyclic structure
1) The While loop is shown in the N-S figure 1-11, the condition is true when the loop body A is executed, until the condition is false to jump out of the loop.
2) n-S diagram of the do-while-type cycle 1-1 2, the loop body A is continuously executed until the condition is false to jump out of the loop.
Example 1-1 of the N-S Figure 1-1 3, example 1-2 of the N-S figure 1-1 4. It should be said that the N-S diagram is more straightforward and relatively concise than the flowchart.

Using pad graph to describe algorithm
Pad (problem analysis Diagram), is a software development in recent years, is widely used in the graphical representation of an algorithm, compared with the above flow chart, n-S diagram, the flow chart, n-S diagram is a top-down sequence description, and pad map in addition to the top-down, There is a left-to-right expansion, so, if the flowchart, N-S diagram is a one-dimensional algorithm description, then the pad is two-dimensional, it can show the hierarchical structure of the algorithm, more intuitive and understandable. Here are some basic forms of the pad diagram:
1. Sequential structure:
shown in 1-1 5.
2. Select structure
(1) Single branch selection, the condition is true to execute a,1-16 a).
(2) Two branch selection, 1-16 b), the condition is true to execute a, B for false execution.
(3) Multi-branch selection, 1-16 c), when I = I1 executes a,i= I2 when executing b,i = I3 when executing c,i = I4 when executing d.

3. Cyclic structure
Shown in 1-1 7. Figure 1-17 A) is a while loop, and figure 1-17 B) is a do-while loop.

This chapter is Example 1. PA d in Fig. 1, Figure 1-1 8, example 1-2, figure 1-1 9

Flowchart related Specifications

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.