How to make a block diagram of an algorithm. Loops with counters. Linear type of algorithms

Often, in order to better understand a task and implement it faster, they use various schemes, tables and charts. Our selection includes 6 services for working with them.

To simplify the process of explanation and development, it is very convenient to use flowcharts. A flowchart is a type of diagram that allows you to describe algorithms or processes. They are often used to work with complex tasks consisting of many points. We have made a selection of 6 tools that will help you create such diagrams. Most of them do not require payment.

6 tools for working with flowcharts:

draw.io

This service will allow you to create not only flowcharts, but also UML, entity-relationship diagrams, network diagrams, electrical circuits, wireframe diagrams and models. Intuitive interface and a large library of elements will allow you to work easily and comfortably. It is also important that several people can work on one project at once. The result can be saved in PNG/JPG/XML/SVG/PDF formats. There is integration with Google Drive.

gliffy.com

Gliffy provides a similar set of tools and capabilities: a large library of elements, user-friendly interface, possibility of collective work, integration with Google Drive, work with Visio documents, ready-made color themes for projects.

gomockingbird.com

The program has a simple and intuitive UI, works in a browser, and allows you to work in a team. Also, by adding links, you can combine several projects into one.

lucidchart.com

An online service that makes it easier to create sketches and diagrams. Compatible with G Suite and Microsoft documents Visio. Once finished, you can export the file to various formats, or send for publication.

Balsamiq mockups

The program allows you to create mockups, diagrams, and various diagrams. There is an extensive library of elements with which you can create any project. The application requires installation on your computer, and is also paid, but you can use trial period web versions.

A flowchart is a form of formalized recording of an algorithm or process. Each step of the algorithm in this submission depicted in the form of blocks of various shapes, which are connected by lines. In a flowchart, you can display all stages of solving any problem, starting with input of initial data, processing by operators, execution of cyclic and conditional functions, and ending with the operations of outputting the resulting values.

Instructions

As a rule, at the beginning of the algorithm, the initial data is entered to solve the problem. Draw a parallelogram below the line so that it is a continuous extension of the diagram. In a parallelogram, write the action being performed, usually these are data operations from the screen (Read nInp) or other devices. It is important that the variables you enter in this step will be used later throughout the body of the flowchart.

The execution of one or a group of operations, any data processing (changing a value or presentation form) is indicated by a rectangle. Draw this figure in the right place in the algorithm when drawing up a block diagram. Inside the rectangle, write down the actions performed, for example, the assignment operation is written as follows: mOut = 10*nInp b + 5. Next, also to continue the flowchart, draw a line down.

An important component of any algorithm and, accordingly, a flowchart are conditional and cyclic operators. These operators have one input and two or more alternative outputs. After calculating the condition specified by the operator, further transition is carried out along only one path. Draw the entrance to the element as a line entering the top vertex of the element.

To specify a condition operator, draw a diamond from this line. Inside the figure, indicate the condition itself and draw lines indicating the further transition depending on its fulfillment. The condition is set in general case comparison operations (>,<, =). Переход по линии вниз осуществляется при истинном условии, назад – при ложном. Укажите около выходных линий фигуры результаты условия (true, false). Невыполнение условия (false) возвращает к определенному шагу выше по телу алгоритма. Проведите линии под прямым углом от выхода с условия и до нужного оператора.

STATE STANDARD OF THE USSR UNION

UNIFIED SOFTWARE DOCUMENTATION SYSTEM

DIAGRAMS OF ALGORITHMS, PROGRAMS, DATA AND SYSTEMS

CONVENTIONS AND IMPLEMENTATION RULES

GOST 19.701-90
(ISO 5807-85)

USSR STATE COMMITTEE FOR PRODUCT QUALITY MANAGEMENT AND STANDARDS

STATE STANDARD OF THE USSR UNION

Date of introduction 01.01.92

This standard applies to conventions (symbols) in diagrams of algorithms, programs, data and systems and establishes rules for the execution of diagrams used to display various types of data processing problems and means for solving them.

The standard does not apply to the form of entries and symbols placed within or adjacent to symbols that serve to clarify the functions they perform.

The requirements of the standard are mandatory.

1. GENERAL PROVISIONS

1.1. Diagrams of algorithms, programs, data and systems (hereinafter referred to as diagrams) consist of symbols with a given meaning, short explanatory text and connecting lines.

1.2. Schemas can be used at different levels of detail, with the number of levels depending on the size and complexity of the data processing problem. The level of detail should be such that the various parts and the relationships between them are understood as a whole.

1.3. This standard defines symbols for use in data processing documentation and provides guidance on conventions for use in:

1) data schemas;

2) program diagrams;

3) schemes of system operation;

4) schemes of program interaction;

5) system resource diagrams.

1.4. The standard uses the following concepts:

1) basic symbol - a symbol used in cases where the exact type (type) of a process or storage medium is unknown or there is no need to describe the actual storage medium;

2) specific symbol - a symbol used in cases where the exact type (type) of a process or storage medium is known or when it is necessary to describe the actual storage medium;

3) diagram - a graphical representation of the definition, analysis or method of solving a problem, in which symbols are used to display operations, data, flow, equipment, etc.

2. DESCRIPTION OF THE CIRCUIT

2.1. Data Schema

2.1.1. Data schemas represent the path of data in solving problems and define the processing steps as well as the various storage media used.

2.1.2. The data schema consists of:

1) data symbols (data symbols can also indicate the type of data carrier);

2) symbols of the process that should be performed on the data (process symbols can also indicate functions performed by the computer);

3) line symbols indicating data flows between processes and (or) storage media;

2.1.3. Data symbols precede and follow process symbols. The data schema begins and ends with data characters (except for special characters, ).

2.2. Program outline

2.2.1. Program diagrams display the sequence of operations in a program.

2.2.2. The program scheme consists of:

1) process symbols indicating the actual data processing operations (including symbols defining the path that should be followed, taking into account logical conditions);

2) linear symbols indicating control flow;

3) special symbols used to make the diagram easier to write and read.

2.3. System operation diagram

2.3.1. System operation diagrams depict the control of operations and the flow of data in the system.

2.3.2. The system operation scheme consists of:

1) data symbols indicating the presence of data (data symbols may also indicate the type of data carrier);

2) process symbols, indicating the operations that should be performed on the data, and also defining the logical path that should be followed;

3) linear symbols indicating data flows between processes and (or) storage media, as well as control flow between processes;

4) special symbols used to make the flowchart easier to write and read.

2.4. Program interaction diagram

2.4.1. Program interaction diagrams display the path of program activation and interaction with the corresponding data. Each program in the program interaction diagram is shown only once (in the system operation diagram, a program can be displayed in more than one control flow).

2.4.2. The program interaction scheme consists of:

1) data symbols indicating the presence of data;

2) process symbols indicating the operations that should be performed on the data;

3) linear symbols depicting the flow between processes and data, as well as the initiation of processes;

4) special symbols used to make the diagram easier to write and read.

2.5. System resource diagram

2.5.1. System resource diagrams display the configuration of data and processing units that is required to solve a task or set of tasks.

2.5.2. The system resource diagram consists of:

1) data symbols displaying the input, output and storage devices of the computer;

2) process symbols representing processors (central processing units, channels, etc.);

3) linear symbols displaying data transfer between I/O devices and processors, as well as transfer of control between processors;

4) special symbols used to make the diagram easier to write and read.

Examples of circuit implementation are given in.

3. DESCRIPTION OF SYMBOLS

3.1. Data symbols

3.1.1. Basic data symbols

3.1.1.1. Data

The symbol displays data, the storage medium is not defined.

3.1.1.2. Memorized data

The symbol displays the stored data in a form suitable for processing; the storage medium is not defined.

3.1.2. Specific data characters

3.1.2.1. Random Access Memory

The symbol displays the data stored in the random access memory device.

3.1.2.2. Serial access memory

The symbol represents data stored in a serial access storage device (magnetic tape, magnetic tape cassette, tape cassette).

3.1.2.3. Direct access storage device

The symbol represents data stored in a direct access storage device (magnetic disk, magnetic drum, floppy disk).

3.1.2.4. Document

The symbol displays data presented on the medium in a readable form (machine diagram, document for optical or magnetic reading, microfilm, roll of tape with summary data, data entry forms).

3.1.2.5. Manual input

The symbol displays data entered manually during processing from any type of device (keyboard, switches, buttons, light pen, barcode strips).

3.1.2.6. Map

The symbol displays data presented on a card-like medium (punched cards, magnetic cards, cards with readable tags, cards with a tear-off label, cards with scannable tags).

3.1.2.7. Paper tape

The symbol displays data presented on a medium in the form of a paper tape.

3.1.2.8. Display

The symbol displays data presented in human-readable form on a medium in the form of a display device (visual observation screen, information input indicators).

3.2. Process symbols

3.2.1.Basic process symbols

3.2.1.1. Process

The symbol represents a data processing function of any kind (performing a specific operation or group of operations that results in a change in the value, form, or arrangement of information, or in determining which of several directions of flow should be followed).

3.2.2. Process specific symbols

3.2.2.1. Predefined process

The symbol displays a predefined process consisting of one or more operations or program steps that are defined elsewhere (in a subroutine, module).

3.2.2.2. Manual operation

The symbol represents any process performed by a person.

3.2.2.3. Preparation

The symbol represents the modification of an instruction or group of instructions to affect some subsequent function (setting a switch, modifying an index register, or initializing a program).

3.2.2.4. Solution

The symbol represents a decision or switch-type function that has one input and a number of alternative outputs, one and only one of which can be activated after evaluating the conditions defined within the symbol. The corresponding calculation results can be written adjacent to the lines representing these paths.

3.2.2.5. Parallel activities

The symbol represents the synchronization of two or more parallel operations.

Example.

Note. Processes C, D and E cannot start until process A has completed; similarly, process F must wait for processes B, C, and D to complete, but process C may start and/or complete before process D starts and/or completes, respectively.

3.2.2.6. Loop boundary

The symbol, consisting of two parts, represents the beginning and end of the cycle. Both parts of the symbol have the same identifier. Conditions for initialization, increment, termination, etc. are placed inside the symbol at the beginning or end, depending on the location of the operation that checks the condition.

Example.

3.3. Line symbols

3.3.1.Basic line symbol

3.3.1.1. Line

The symbol represents the flow of data or control.

Directional arrows may be added as needed or to improve readability.

3.3.2.Specific line symbols

3.3.2.1. Transfer of control

The symbol represents a direct transfer of control from one process to another, sometimes with the possibility of a direct return to the initiating process after the initiated process has completed its functions. The type of control transfer must be named within the symbol (eg request, call, event).

3.3.2.2. Link

The symbol displays data transmission over the communication channel.

3.3.2.3. Dotted line

A symbol represents an alternative relationship between two or more symbols. In addition, the symbol is used to outline the annotated area.

Example 1.

When one of a number of alternative outputs is used as an input to a process, or when an output is used as an input to alternative processes, these symbols are connected by dotted lines.

Example 2.

An output used as an input to the next process can be connected to that input using a dotted line.

3.4. Special symbols

3.4.1. Connector

The symbol represents the exit to part of the circuit and the entrance from another part of this circuit and is used to break a line and continue it in another place. Corresponding connector symbols must contain the same unique designator.

3.4.2. Terminator

The symbol represents output to the external environment and input from the external environment (beginning or end of the program diagram, external use, and source or destination of data).

3.4.3.A comment

The symbol is used to add descriptive comments or explanatory notes for the purpose of explanation or notes. The dotted lines in a comment symbol are associated with a corresponding symbol or can outline a group of symbols. The text of comments or notes should be placed near the bounding shape.

Example.

3.4.4. Pass

The symbol (three dots) is used in diagrams to indicate the omission of a symbol or group of symbols in which neither the type nor the number of symbols is specified. The symbol is used only within or between line symbols. It is used mainly in diagrams depicting general solutions with an unknown number of repetitions.

Example.

4 RULES FOR THE APPLICATION OF SYMBOLS AND EXECUTION OF DIAGRAMS

4.1. Rules for using symbols

4.1.1. A symbol is intended to graphically identify the function it represents, regardless of the text within that symbol.

4.1.2. The symbols in the diagram should be evenly spaced. Keep connections to a reasonable length and keep the number of long lines to a minimum.

4.1.3. Most symbols are designed to allow text to be included within the symbol. The symbol forms specified in this standard are intended to serve as a guide for the symbols actually used. Angles and other parameters that affect the appropriate shape of the symbols should not be changed. Symbols should be the same size if possible.

Characters can be drawn in any orientation, but horizontal orientation is preferred whenever possible. Mirroring the shape of a character denotes the same function, but is not preferred.

4.1.4. The minimum amount of text necessary to understand the function of a given symbol should be placed within the given symbol. Reading text should be written from left to right and top to bottom, regardless of the direction of flow.

Example.

If the amount of text placed inside a symbol exceeds its dimensions, a comment symbol should be used.

If the use of comment symbols could confuse or disrupt the flow of the diagram, the text should be placed on a separate sheet and a cross-reference to the symbol should be provided.

4.1.5. Schemes may use a symbol identifier. This is the identifier associated with a given symbol, which identifies the symbol for reference use in other documentation elements (for example, a program listing). The symbol ID should be located to the left above the symbol.

Example.

4.1.6. Diagrams may use symbol descriptions—any other information, for example to show a special use of a symbol with a cross-reference, or to enhance understanding of a function as part of a diagram. The description of the symbol should be located to the right above the symbol.

Example.

4.1.7. In system diagrams, symbols representing storage media often represent input/output methods. To be used as a reference to documentation, the text on the diagram for symbols representing output methods should be placed to the right above the symbol, and the text for symbols representing input methods should be placed to the right below the symbol.

Example.

4.1.8. Diagrams may use a detailed representation, which is indicated by a bar symbol for process or data. The bar symbol indicates that more detailed information is available elsewhere in the same documentation set.

A stripe symbol is any symbol that has a horizontal line drawn inside it at the top. Between this line and the top line of the symbol is an identifier indicating a detailed representation of that symbol.

The terminator character must be used as the first and last character of the verbose representation. The first terminator character must contain a reference, which is also present in the bar character.

Symbol with stripe Detailed view

4.2. Rules for making connections

4.2.1. Data flows or control flows in diagrams are shown as lines. The flow direction from left to right and from top to bottom is considered standard.

In cases where it is necessary to bring greater clarity to the diagram (for example, when making connections), arrows are used on the lines. If the flow is in a direction other than the standard one, the arrows should indicate that direction.

4.2.2. Intersecting lines should be avoided in diagrams. Intersecting lines have no logical connection with each other, therefore changes in direction at the intersection points are not allowed.

Example.

4.2.3. Two or more incoming lines can be combined into one outgoing line. If two or more lines merge into one line, the location of the merge must be shifted.

Example.

4.2.4. Lines in diagrams should approach the symbol either from the left or from above, and originate either from the right or from below. The lines should be directed towards the center of the symbol.

4.2.5. If necessary, lines in diagrams should be broken to avoid unnecessary intersections or too long lines, and also if the diagram consists of several pages. The connector at the beginning of a break is called an outer connector, and the connector at the end of a break is called an inner connector.

Example.

External connector Internal connector

4.3. Special conventions

4.3.1. Multiple exits

4.3.1.1. Multiple exits from a symbol should be shown:

1) several lines from this symbol to other symbols;

2) one line from a given symbol, which then branches into the corresponding number of lines.

Examples.

4.3.1.2. Each symbol output must be accompanied by corresponding condition values ​​to show the logical path it represents, so that those conditions and corresponding references are identified.

Examples.

4.3.2. Repeating view

4.3.2.1. Instead of a single symbol with associated text, multiple overlapping symbols, each containing descriptive text, may be used (using or generating multiple storage media or files, producing multiple copies of printed reports or punched card formats).

4.3.2.2. When multiple characters represent an ordered set, the ordering must be from front (first) to back (last).

4.3.2.3. Lines can enter or originate from any point on the overlapping symbols, but the requirements must be met. The priority or sequential order of multiple symbols is not changed by the point at which a line enters or departs.

Example.

5. APPLICATION OF SYMBOLS

Symbol name

Data Schema

Program outline

System operation diagram

Program interaction diagram

System resource diagram

Data symbols

Basic

Memorized data

Specific

Random Access Memory

Sequential Access Memory

Direct access storage device

Document

Manual input

Paper tape

You will need

  • - stencil for drawing block diagrams;
  • - mechanical pencil;
  • - eraser;
  • - paper;
  • - a computer with Internet access.

Instructions

The beginning and end of the algorithm are indicated by ovals. The words “Beginning” and “End” are placed inside them, respectively. From the oval, symbolizing the beginning of the algorithm, one arrow comes down, and an arrow from above comes to the oval, symbolizing the end of the algorithm.

Steps corresponding to non-I/O activities are indicated using rectangles. An example of such an action is the calculation and assignment of the result to a particular variable. The arrow from the previous step comes to the rectangle from above, and the arrow to the next step comes from below it.

Parallelograms are used to represent steps corresponding to I/O operations. There are two types of such operations: assigning data received from somewhere to a variable and outputting data from a variable to a file, port, printer, etc.

Branches are indicated by diamonds. The arrow from the previous step comes to the top corner of the diamond, and arrows like “No” and “Yes” come from its side corners. They come, respectively, to the steps performed when the condition is not met and when the condition is met. The bottom corner of the diamond is left free. Itself (for example, equality, strict or non-strict) inside a diamond.

A rectangle with double side walls represents the transition to the subroutine. After a return statement is encountered in a subroutine, execution of the main program continues. The name of the subroutine is indicated inside. Block diagrams of all subroutines are placed under the block diagram of the main program or on separate pages.

If you would like to create flowcharts electronically, use an application called Flowchart. If you wish, you can also master special programming languages ​​in which the programming process itself consists of drawing up a flowchart. There are two such languages: Dragon and HiAsm.

Sources:

  • how to draw a block diagram

A flowchart is a form of formalized recording of an algorithm or process. Each step of the algorithm in this representation is depicted in the form of blocks of various shapes, which are connected by lines. In a flowchart, you can display all stages of solving any problem, starting with input of initial data, processing by operators, execution of cyclic and conditional functions, and ending with operations for outputting the resulting values.

Instructions

As a rule, at the beginning of the algorithm, the initial data is entered to solve the problem. Draw a parallelogram below the line so that it is a continuous extension of the diagram. In a parallelogram, write the action being performed, usually these are data operations from the screen (Read nInp) or other devices. It is important that the variables you entered in this step will be used later throughout the body of the flowchart.

The execution of one or a group of operations, any data processing (changing a value or presentation form) is indicated by a rectangle. Draw this figure at the right place in the algorithm when drawing up the flowchart. Inside the rectangle, write down the actions performed, for example, the assignment operation is written as follows: mOut = 10*nInp b + 5. Next, also to continue the flowchart, draw a line down.

An important component of any algorithm and, accordingly, a flowchart are conditional and cyclic operators. These operators have one input and two or more alternative outputs. After calculating the condition specified by the operator, further transition is carried out along only one path. Draw the entrance to the element as a line entering the top vertex of the element.

To specify a condition operator, draw a diamond from this line. Inside the figure, indicate the condition itself and draw lines indicating the further transition depending on its fulfillment. The condition is set in the general case by comparison operations (>,<, =). Переход по линии вниз осуществляется при истинном условии, назад – при ложном. Укажите около выходных линий фигуры результаты условия (true, false). Невыполнение условия (false) возвращает к определенному шагу выше по телу алгоритма. Проведите линии под прямым углом от выхода с условия и до нужного оператора.

The cyclic operator is denoted by rectangles with beveled corners. Moreover, to draw this operator, two boundary figures are used. The beginning of the cycle is specified by a figure with beveled upper corners, the end of the cycle is defined by a figure with beveled lower corners. In the shape of the beginning of the loop, indicate the condition for the loop and between the boundary shapes draw loop operators.

At the end of the flowchart, the output of the resulting data to media or to the screen should be indicated. The output statement is drawn similarly to the input statement. Draw a parallelogram and the inference operations within it using output variables.

A flowchart is a universal form of expressing an algorithm, which can then be translated into any programming language. It is created in a form suitable for human reading. This allows you to check the correctness of the algorithm manually.

Instructions

At the end of each of the lines connecting the elements of the block diagram to each other, apply. This will allow you to more accurately determine the order of actions, especially if the algorithm is branched.

Development of a block diagram of an algorithm for solving a problem

Goal of the work: studying a graphical method of describing an algorithm for solving a problem.

Job Objectives:

    become familiar with the main ways of presenting algorithms;

    master the graphical method of describing algorithms.

1.1. Work order

    Study the theoretical information on the topic of this section (section 1.2)

    Read the problem statement (section 1.3). The task option corresponds to your number on the group list.

    Develop a block diagram of an algorithm for solving the problem.

    Answer the security questions.

    Prepare a report on the implementation of practical work, which should contain:

    title page;

    purpose of practical work;

    problem statement;

    block diagram of the algorithm for solving the problem;

    answers to security questions;

    conclusions from practical work.

1.2. General information

One of the most labor-intensive stages of solving a problem on a computer is developing an algorithm.

Under algorithm is understood as an exact prescription that defines the computational process leading from varying initial data to the desired result.

The main characteristic properties of the algorithm are:

    determinism (certainty) – given the initial data, the unambiguity of the desired result is ensured;

    mass character – suitability for tasks of a given type with initial data belonging to a given subset;

    efficiency - the implemented computational process is performed in a finite number of stages with the output of a meaningful result;

    discreteness – the ability to split the algorithm into separate stages, the implementation of which is beyond doubt.

The following are distinguished: types of computing processes:

    Linear computational process.

To obtain the result, it is necessary to perform certain operations in a certain sequence.

    Branched computing process.

The specific sequence of operations depends on the values ​​of one or more parameters. For example, if the discriminant of a quadratic equation is not negative, then the equation has two roots, and if it is negative, then there are no real roots.

    Cyclic computing process

To obtain a result, a certain sequence of actions must be performed several times. For example, in order to obtain a table of function values ​​at a given interval of argument change with a given step, it is necessary to determine the next argument value an appropriate number of times and calculate the function value for it.

In turn, there are also several types of cyclic computing process, namely:

    WITH even cycles (cycles with a given number of repetitions) – These are cyclic processes for which the number of repetitions is known.

    Iterative loops are cyclic processes that end when certain conditions are met or violated.

    P search cycles – These are cyclical processes, from which there are two possible exits:

Exit when the process is completed;

Early exit under any additional condition.

Based on the type of computational process implemented by the algorithm, there are:

Linear structure algorithms;

Branched structure algorithms;

Algorithms for cyclic structure.

Algorithms for solving practical problems usually have a combined structure, that is, they include all three types of computational processes.

Visual means of describing algorithms include the following main ways of representing them:

Verbal (natural language recordings);

Structural-stylized (records in algorithmic language and pseudocode);

Graphic (image of diagrams and graphic symbols);

Programming (texts in programming languages).

Verbal method description of the algorithm is a description of successive numbered stages of data processing and is given in any form in natural language.

Example 1.1.

Algorithm for adding two numbers (a and b).

    Ask what the number a is equal to.

    Ask what the number b is equal to.

    Add a and b, assign the result to c.

    Report result c.

Dignity this method is the simplicity of the description, and the disadvantages include the fact that this approach is verbose and does not have strict formalization, therefore it allows for ambiguity in the interpretation of individual instructions, due to which the verbal method of presenting the algorithm is not widespread.

To strictly specify various data structures and algorithms for their processing, it is necessary to have such a system of formal notations and rules so that the meaning of any used prescription is interpreted accurately and unambiguously. The corresponding systems of rules are called description languages. These include algorithmic languages ​​(pseudocodes), flowcharts, and programming languages.

Structural stylized way algorithm description is based on recording algorithms in a formalized representation of instructions, specified by using a limited set of standard syntactic structures, often called pseudocodes.

The advantage of pseudocodes is their proximity to programming languages, and the disadvantages, in turn, are the difficulty of mastering and the impossibility of directly entering the algorithm for solution on a computer, i.e. the need for translation into a programming language.

Graphic method description of the algorithm assumes that to describe the structure of the algorithm, a set of graphic images (blocks) connected by control transmission lines is used. This image is called block diagram method.

Block diagram An algorithm is a graphical representation of the progress of solving a problem. A flowchart consists of blocks connected by lines, and the blocks are depicted as geometric shapes called symbols. Inside the symbols, instructions about the functions performed by the block are written - formulas, text, logical expressions. The type of symbols and rules for executing block diagrams are standardized - GOST 19.701-90 contains a list of symbols, their names, displayed functions, shapes and sizes, as well as rules for executing diagrams. When developing an algorithm, each action is designated by a corresponding block, showing their sequence with lines with arrows at the end. The names, designations and purpose of block diagram elements are shown in Fig. 1.1.

Figure 1.1 – Main blocks

It is worth mentioning some basic rules for executing flowcharts that should be followed when describing algorithms graphically. The beginning of the algorithms is marked by the “Terminator” symbol, from which one line emerges. The word “Start” (“Start”) is written in it. The end of the algorithm is marked with the same symbol, in which the word “Stop” (“End”) is written. In this case, this symbol does not have a single output line, but one or more lines can be connected to it. The Process symbol can have one or more input lines and only one output line. Several instructions can be written inside a symbol - in this case they are carried out in the order they were written. The presentation of individual operations is quite free. To indicate calculations, you can use mathematical expressions, to send data - arrows, for other actions - explanations in natural language, for example, A: = X + 4; i: = i + 1, ––> B.

The flow lines should be parallel to the sides of the sheet. The main directions of flow lines - from top to bottom and from left to right - are not indicated by an arrow. In other cases, an arrow is placed at the end of the flow line, and a dot is placed where the lines merge. If the block diagram does not fit on one sheet, connectors are used. When moving to another sheet or receiving control from another sheet, the sheet number is indicated in the comment, for example, “from sheet 3” “to sheet 1”.

To write an algorithm of any complexity it is enough three basic structures:

    following - denotes the sequential execution of actions (Fig. 1.2, a);

    branching - corresponds to the choice of one of two options for action (Fig. 1.2, b);

    cycle-bye - defines repetition of actions, until the condition is violated, the fulfillment of which is checked at the beginning of the cycle (Fig. 1.2, c).

Figure 1.2 – Basic algorithmic structures

In addition, when describing algorithms, we use additional algorithmic structures, derived from the basic ones, each of which can be implemented through basic structures:

    choice - choosing one option from several depending on the value of a certain quantity (Fig. 1.3, a, b);

    cycle-to- repeating some actions until a given condition is met, which is checked after performing the actions in the cycle (Fig. 1.3, c, d);

    cycle with given number reps (counting cycle) repeating some actions a specified number of times (Fig. 1.3, e, f).

Figure 1.3 – Implementation of additional algorithmic structures

through basic structures

Let's look at examples graphic description algorithms of various types: linear, branching, cyclic and combined (Fig. 1.4 – 1.7).

Example 1.2. Linear algorithm.

Algorithm for calculating the value of the expression K=3b+6a (Fig. 1.4).

Figure 1.4 – Example of a linear algorithm block diagram

Example 1.3. Branching algorithm.

An algorithm that determines whether the graph of the function y=3x+4 will pass through the point with coordinates x1,y1 (Fig. 1.5).

Figure 1.5 – Example of a block diagram of a branching algorithm

Example 1.4. Cyclic algorithm.

Algorithm that determines the factorial of a natural number n (Fig. 1.6):

n! = 1*2*3*….*(n-1)* n

5!=1*2*3*4*5=120

Figure 1.6 – Example of a block diagram of a cyclic algorithm

Example 1.5. Combined algorithm.

It is necessary to determine the greatest common divisor of two natural numbers A and B.

To solve the problem, we use the Euclidean algorithm, which consists of sequentially replacing the larger number with the difference of the larger and smaller numbers until the numbers become equal. Let's look at this algorithm using two examples.

Example (a): A=225, B=125. Applying the Euclidean algorithm, we obtain for A and B the greatest common divisor equal to 25.

Example (b): A=13, B=4. In this case, the greatest common divisor of A and B is 1.

B

50-25=25

A block diagram of the Euclidean algorithm for finding the greatest common divisor of two natural numbers is shown in Fig. 1.7.

Figure 1.7 – Example of a block diagram of a combined algorithm

The flowchart of an algorithm displays in detail all the features of the developed algorithm, but sometimes such a high level of detail does not allow the essence of the algorithm to be highlighted. In these cases, the algorithm is described using pseudocode. Pseudocode is based on the same basic structures as the block diagrams of the algorithm (Table 1.1).

Example 1.6. Description of the Euclidean algorithm in pseudocode.

Euclid's algorithm:

Enter A, B

cycle-bye A ≠ B

If A > B

That A:= A - B

otherwise B:= B - A

all - if

all-cycle

Output A

End of the algorithm.

Table 1.1 – Example of pseudocode for writing basic algorithmic structures

Structure

Pseudocode

Structure

Pseudocode

Following

Choice

All-choice

Branching

If

given

number of repetitions

For =

otherwise

All - if

All-cycle

Cycle-bye

Cycle-bye

Fulfill

All-cycle

1.3. Problems for drawing up flowcharts of algorithms

    Given an integer m>1.

Find the smallest integer k such that 4 k >m.

Calculate product

    An integer n is given.

Get the smallest number of the form 2 r that exceeds n (r is a natural number).

    Given integers n, k (n  k  0).

Calculate.

    Given natural number n and a real number a.

Calculate the product.

    Given a natural number n.

Calculate Sum .

    Given a real number x and a natural number n.

Calculate without using exponentiation.

    Given a natural number n.

Calculate the amount:

    Are given real numbers x and a, natural n.

Calculate:

Calculate:

    Given natural numbers n, m. Get the sum of the last m digits of number n.

    Let n be a natural number. Calculate the amount.

    Given a natural number n.

Calculate the amount:

Control questions

    Define an algorithm.

    List the main properties of algorithms and reveal their essence.

    How are algorithms divided according to the type of computational process being implemented?

    What ways of describing algorithms do you know?

    What is meant by graphically descriptions of algorithms? What is the advantage of this method over a verbal description of the algorithm?

    Coursework >> Computer Science

    Weights of the edges of the remaining tree. 2.4 Block-scheme Figure 7 – Block-scheme algorithm solutions tasks 2.5 Justification for choosing the programming language Turbo..., an integrated environment that greatly speeds up the process development programs. This software passed...

  1. Algorithms and programming basics

    Practical work >> Computer science, programming

    Programming solutions various tasks on electronic computers; science dealing with development methods... . Block-scheme given linear algorithm shown in Figure 4. Example 1. Calculate at x=2.3 In general, algorithm solutions ...

  2. Construction block schemes algorithms. High-level algorithmic languages

    Abstract >> Computer Science

    Approach to decision delivered tasks. Tasks implemented on three various languages programming. Block-scheme algorithms, program listings... time. Algorithm solutions tasks turns out to be more effective if you use the step-by-step method development, the point...

  3. System and software

    Abstract >> Computer Science

    ... : Development block scheme algorithm solutions tasks for monitoring the knowledge of FPK students. DescriptionFFffuvvya blocks scheme algorithm solutions tasks. Block 1 ... – enter a name (designation) tasks, enter...