Give names to the figures in the block diagram. Make your flowchart simple and easy to understand in just a couple of simple steps. Convenient construction of logical chains with Draw. io

8.2. Algorithm flowcharts

Flowcharts (Basic Flowchart) have long been successfully used to describe algorithms. The construction of block diagrams of algorithms is regulated by GOST 19.701-90 (ISO 5807-85) " one system program documentation. Algorithm diagrams for programs, data and systems. Symbols and implementation rules." This state standard is compiled on the basis international standard"ISO 5807-85. Information processing – Documentation symbols and conventions for data, program and system flowcharts, program network charts and system resources charts".

According to GOST 19.701-90 under scheme is understood graphical representation definition, analysis, or method for solving a problem. Diagrams can be used to depict both static and dynamic aspects of a system. The symbols given in the state standard can be used in the following circuit types :

Data schemas – determine the sequence of data processing and their media;

Program diagrams - display the sequence of operations in the program (in fact, these are flowcharts of algorithms in the traditional sense);

System operation diagrams – display the management of operations and data flows in the system;

Program interaction diagrams – display the path of activation of programs (modules) and their interaction with the corresponding data;

System resource diagrams - display the configuration of data blocks and processing blocks.

As can be seen from the above types of diagrams, they can be used not only for modeling the behavioral aspect, but also for functional, information and component design problems.

When constructing a behavioral model of the system, the basic principles of the structural approach are used - the principles of decomposition and hierarchical ordering. A behavioral model is a set of interrelated schemes (diagrams) with different levels detail, and with each new level of detail the system acquires more and more complete outlines.

The diagrams may include the following: elements of graphic notation :

Data symbols - indicate the presence of data, the type of media, or the method of input/output of data;

Process symbols - indicate the operations that should be performed on the data;

Line symbols - indicate data flows between processes and/or storage media, as well as control flows between processes;

Special characters – used to make diagrams easier to write and read.

In addition to dividing according to semantic content, each category of symbols (except special ones) is divided into basic and specific symbols. Basic symbol used when the exact type of process or storage medium is unknown or there is no need to describe the actual storage medium (process). Specific symbol used when the exact type of process or storage medium is known and this needs to be shown on the diagram. The following table shows the elements of graphical flowchart notation.

Table 8.1. Symbols on block diagrams

No. Symbol Name Notes
1. DATA SYMBOLS
Basic
1.1 Data Data whose carrier is not defined
1.2 Storage device (memory) Data stored in a form suitable for automatic processing, carrier not defined
Specific
1.3 RAM Data stored in RAM (random access memory)
1.4 memory with sequential access Data stored on magnetic tape (magnetic tape, tape cassette)
1.5 Direct access memory Data stored on hard or flexible magnetic disks, CD, DVD, ZIP, etc.
1.6 Document Data not provided in computer form(on paper, on films, etc.)
1.7 Manual input Data entered manually using a keyboard, mouse, pen, etc.
1.8 Map Data on punched cards, magnetic cards, readable tag cards, etc.
1.9 Paper tape Data on paper tape
1.10 Display Data displayed on the monitor screen, signal indicators, etc.
2. PROCESS SYMBOLS
Basic
2.1 Process Elementary (atomic) data processing operation (for example, n:=n+1)
Specific
2.2 Predefined process (procedure) A process consisting of operations described elsewhere (on another diagram)
2.3 Manual operation Manual operation
2.4 Preparation Preparatory operations performed to modify subsequent operations (loop with parameter)
2.5 Solution An operation with one input and several alternative outputs, one of which is activated after testing the condition written inside the symbol (If-Then-Else or Case statements)
2.6 Parallel activities Parallel execution of two or more operations
2.7 Cycle boundaries The beginning and end of the cycle. Features of the loop (initialization, increment, condition) are recorded at the beginning or end, depending on where it is checked (cycles with pre- or postcondition)
3. LINE SYMBOLS
Basic
3.1 Line Data or control flow
Specific
3.2 Link Data transmission via communication channel
3.3 Dotted line An alternative connection between two or more symbols or for outlining a commented section of the diagram
4. SPECIAL CHARACTERS
4.1 GOST Connector Used to break lines and continue them elsewhere.
Typically used to indicate interconnected parts of a circuit in different sheets. The connection number is written inside the connector
ISO
4.2 Terminator Exit to the external environment or entry from external environment(the beginning and end of a data processing process [in this case they write “beginning” or “end” inside], the source or destination of data, the beginning and end of a predefined process)
4.3 Recipient sender Functionally similar to the "Terminator" symbol
4.4

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. Schemes of algorithms, programs, data and systems (hereinafter referred to as schemes) consist of having set value symbols, short explanatory text and connecting lines.

1.2. Schemes can be used on various levels detail, with the number of levels depending on the size and complexity of the data processing task. 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 how to symbols 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 (kind) 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 may also indicate the type of storage medium);

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 symbols (except 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 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 depict 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 displaying 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 medium in the form of a card (punched card, 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 placement of information, or in determining which of several flow directions to follow).

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 two-part symbol 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 mainly used in circuits 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, if possible, the same size.

Characters can be drawn in any orientation, but horizontal orientation is preferred whenever possible. Mirror image forms of the symbol denote the same function, but are not preferred.

4.1.4. Minimum amount of text required to understand the function of this symbol, should be placed inside this 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. Schemes can use symbol descriptions - any other information, for example, to display special application symbol with a cross-reference, or to improve understanding of a function as part of a circuit. 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

If you don’t really want to scribble sloppily in your notebook, but they force you to draw. Of course, we only consider free options :)

  • draw.io Great free service for online drawing of business diagrams and flowcharts. Saves the file in .xml format, but you can also take a screenshot by disabling the Grid display. Integrates with Google Drive.
  • Google Drawing. Log in to your Google profile, say File - Create - Drawing in the page menu and get a convenient drawing tool, after which you can download it in pdf or popular graphic formats.

Perhaps these services are the best, although there are many alternatives:

  • lucidchart. After a second of registration and selecting Start Free Account, we get convenient and easily scalable schemes, which can then be published and downloaded in the desired format.
  • creatly. "Try creatly now" - and you can draw right away. However, you need to allow loading the flash drive and exporting files is only available to registered users. But no one canceled the screenshots :)
  • iyopro.com. Free project, however, it is in Silverlight and will not run for everyone (for example, it will work in Internet Explorer).
  • gliffy. After a short registration that does not require confirmation, you can immediately start drawing diagrams.
  • cacoo. Positions itself as “Cloud-based diagrams, the easy way”.
  • Violet. Offline UML diagram editor, for advanced :)
  • Block diagram from paslab. A unique domestic service for converting Pascal programs into flowcharts :)

It is extremely important to use the language of flowcharts when developing an algorithm for solving a problem. The solution to the same problem can be implemented using various algorithms, differing from each other both in calculation time and volume of calculations, and in their complexity. Recording these algorithms using flowcharts allows you to compare them, select the best algorithm, simplify, find and eliminate errors.

Refusal from the flowchart language when developing an algorithm and developing the algorithm directly in a programming language leads to significant loss of time and to the choice of a suboptimal algorithm. Therefore, it is necessary to initially develop an algorithm for solving the problem in the language of flowcharts, after which the algorithm is translated into a programming language.

When developing an algorithm difficult task method used step-by-step detailing. The first step is to think through general structure algorithm without detailed study of its individual parts. Blocks that require detail are outlined with a dotted line and are thought through and detailed in subsequent steps of developing the algorithm.

In the process of developing an algorithm for solving a problem, the following stages can be distinguished:

  • Stage 1. Mathematical description of the solution to the problem.
  • Stage 2. Definition of input and output data.
  • Stage 3. Development of an algorithm for solving the problem.

Basic algorithmic designs

In programming theory it has been proven that to write any algorithm, no matter how complex, it is enough three basic structures:

  • following (linear algorithm);
  • branching (branching algorithm);
  • loop-bye (round-robin algorithm).

Linear algorithms

Linear algorithm is formed from a sequence of actions following one after another. For example, to determine the area of ​​a rectangle, you must first set the length of the first side, then set the length of the second side, and only then use the formula to calculate its area.

Example

TASK. Develop an algorithm for calculating the hypotenuse of a right triangle using the known values ​​of the lengths of its legs a and b.

Using this problem as an example, we will consider all three stages of developing an algorithm for solving the problem:

The mathematical solution to the problem is the well-known formula:

,

where c is the length of the hypotenuse, a, b are the lengths of the legs.

The input data is the values ​​of legs a and b. The output is the length of the hypotenuse – c.

Branching Algorithms

contains a condition, depending on which a particular sequence of actions is performed.

Example

TASK. Develop an algorithm for calculating the largest number from two numbers x and y.

Stage 1. Mathematical description of the solution to the problem.

It is known from a mathematics course that if x > y, then greatest number x if x< y, то наибольшее число y, если x = y, то число x равно числу y.

Stage 2. Determination of input and output data.

The input data is the values ​​of the numbers x and y. The output is:

  • greatest number
  • any of the numbers if the numbers are equal

To solve the problem we need to know the values ​​of x and y.

Stage 3. Development of an algorithm for solving the problem.

In the diagram of the algorithm for solving the problem, the numbers of the elements of the algorithm are indicated in numbers, which correspond to the numbers of steps in the verbal description of the algorithm

In the algorithm under consideration (Fig. 3) there are three branches of solving the problem:

  • first: these are elements 1, 2, 3, 4, 8.
  • second: these are elements 1, 2, 3, 5, 6, 8
  • third: these are elements 1, 2, 3, 5, 7, 8.

The choice of branch is determined by the x and y values ​​in elements 3 and 5, which are conditions that determine the order in which the elements of the algorithm are executed. If the condition (equality) written inside the “solution” symbol is satisfied for the entered values ​​of x and y, then elements 4 and 8 are executed next. This follows from the fact that they are connected by a line labeled “yes” and the direction (sequence) of calculations is indicated arrow.

If the condition in element 3 is not met, then element 5 is executed next. It is connected to element 3 by a line labeled “no”. If the condition written in element 5 is met, then elements 6 and 8 are executed, otherwise elements 7 and 8 are executed.

Cyclic algorithms

determines the repetition of some part of the actions (operations) until a condition is violated, the fulfillment of which is checked at the beginning of the cycle. A set of operations performed repeatedly is called the body of a loop.

Algorithms in which individual actions are repeated many times are called cyclic algorithms, The set of actions associated with repetition is called cycle.

When developing a cyclic structure algorithm, the following concepts are distinguished:

  • cycle parameter – a value whose value changes when repeating the cycle;
  • initial and final values ​​of the cycle parameters;
  • cycle step – the value by which the cycle parameter changes with each repetition.

The cycle is organized according to certain rules. Round robin algorithm consists of a loop preparation, a loop body, and a loop continuation condition.

Cycle preparation includes actions related to setting initial values ​​for cycle parameters:

  • initial values ​​of the cycle;
  • loop end values;
  • cycle step.

The body of the loop includes:

  • repeated actions to calculate the required quantities;
  • preparing the next loop parameter value;
  • preparation of other values ​​necessary for repeated execution of actions in the body of the loop.

The cycle continuation condition determines the permissibility of repeating actions. If the loop parameter is equal to or exceeds final value loop, then the loop must be terminated.

Example

TASK. Develop an algorithm for calculating the sum natural numbers from 1 to 100.

Stage 1. Mathematical description of the solution to the problem.

Let us denote the sum of natural numbers by S. Then the formula for calculating the sum of natural numbers from 1 to 100 can be written as follows:

where Xi is a natural number X with number i, which varies from 1 to n, n=100 is the number of natural numbers.

Stage 2. Determination of input and output data.

The input data are natural numbers: 1, 2, 3, 4, 5, …, 98, 99, 100.

Output– the value of the sum of the terms of a sequence of natural numbers.

Loop parameter a value that determines the number of repetitions of the cycle. In our case, i is the number of a natural number.

Cycle preparation consists in setting the initial and final values ​​of the loop parameter.

  • initial value loop parameter is 1,
  • the final value of the loop parameter is n ,
  • The loop step is 1.

For correct summation, you must first set the initial value of the sum to 0.

The body of the loop. In the body of the loop, the value of the sum of numbers will be accumulated, and the next value of the loop parameter will be calculated using the formulas:

Condition for continuing the loop: the cycle must be repeated until the last member of the sequence of natural numbers is added, i.e. until the loop parameter is less than or equal to the final value of the loop parameter.

Stage 3. Development of an algorithm for solving the problem.

Let us introduce the following notation: S is the sum of the sequence, i is the value of the natural number.

The initial value of the cycle is i=1, the final value of the cycle is i =100, the cycle step is 1.

Verbal description of the algorithm Writing an algorithm in flowchart language
  1. The beginning of the algorithm.
  2. Cycle preparation: S:=0; i=1; n= 100;
  3. Checking the condition. If i<=n , то перейти к шагу 4, иначе к шагу 6.
  4. Accumulation of the amount: S:=S+i;
  5. Calculation of the next value of the loop parameter: i:=i+1;
  6. Information output: sum of natural numbers – S.
  7. End of the algorithm.

In the diagram of the algorithm for solving the problem, the numbers of the elements of the algorithm are indicated in numbers. The numbers of elements correspond to the numbers of steps in the verbal description of the algorithm.

Algorithm- an exact final system of rules described in a certain language that determines the content and order of actions on certain objects, the strict implementation of which gives a solution to the problem. The concept of an algorithm, which is fundamental in mathematics and computer science, arose long before the advent of computer technology. The word “algorithm” appeared in the Middle Ages, when Europeans became acquainted with the methods of performing arithmetic operations in the decimal number system, described by the Uzbek mathematician Muhamed bin Al-Khwarizmi. The word algorithm is the result of the European pronunciation of Al-Khwarizmi’s words. Initially, the algorithm was understood as a method of performing arithmetic operations on decimal numbers. Later, this concept began to be used to denote any sequence of actions leading to the solution of a given problem. Any algorithm does not exist on its own, but is intended for a specific performer (human, robot, computer, programming language, etc.). The meaning of the word “ algorithm" is very similar to the meanings of the words "recipe", "method", "process". However, unlike a recipe or process, an algorithm is characterized by the following properties:

discreteness, mass character, certainty, effectiveness, formality.

Discreteness(discontinuity) is a property of an algorithm that characterizes its structure: each algorithm consists of individual completed actions, they say “Divided into steps.”

Mass character- applicability of the algorithm to all problems of the type under consideration, for any initial data. For example, an algorithm for solving a quadratic equation in the domain of real numbers must contain all possible outcomes of the solution, i.e., having considered the values ​​of the discriminant, the algorithm finds either two different roots of the equation, or two equal ones, or concludes that there are no real roots.

Certainty(determinism, accuracy) - a property of an algorithm, indicating that each step of the algorithm must be strictly defined and not allow different interpretations. The order in which the individual steps are performed must also be strictly defined.

Efficiency- a property consisting in the fact that any algorithm must be completed in a finite (maybe very large) number of steps. Formality - this property indicates that any performer capable of perceiving and executing the instructions of the algorithm acts formally, i.e. is distracted from the content of the task at hand and only strictly follows instructions. Reasoning “what, how and why?” The developer of the algorithm must do it, and the performer formally (without thinking) one by one executes the proposed commands and obtains the required result.

1.2.Methods of describing (types) of algorithms.

Consider the following ways to describe the algorithm: verbal description, pseudocode, block diagram, program.

Verbal description represents the structure of an algorithm in natural language. For example, any household appliance (iron, electric saw, drill, etc.) has an instruction manual, i.e. a verbal description of the algorithm in accordance with which this device should be used. There are no rules for composing a verbal description. The algorithm is written in any form in a natural language, for example, Russian. This method of description is not widespread, since it is not strictly formalized (by “formal” we mean that the description is absolutely complete and takes into account all possible situations that may arise during the solution); allows for ambiguity of interpretation when describing certain actions; suffers from verbosity.

Pseudocode- description of the structure of the algorithm in a natural, partially formalized language, allowing one to identify the main stages of solving a problem before writing it exactly in a programming language. Pseudocode uses some formal constructs and common mathematical symbols. There are no strict syntax rules for writing pseudocode. This makes it easier to write the algorithm during design and allows you to describe the algorithm using any set of commands. However, pseudocode usually uses some of the constructs inherent in formal languages, which makes it easier to move from pseudocode to writing an algorithm in a programming language. There is no single or formal definition of pseudocode, so various pseudocodes are possible, differing in the set of words and structures used.

Block diagram- description of the structure of the algorithm using geometric figures with connection lines showing the order of execution of individual instructions. This method has a number of advantages. Thanks to its clarity, it ensures the “readability” of the algorithm and clearly displays the order in which individual commands are executed. In a block diagram, each formal design corresponds to a specific geometric figure or a set of figures connected by lines.

Descriptions of the algorithm in verbal form, in pseudocode or in the form of a flowchart allow some arbitrariness in the depiction of commands. At the same time, they are so sufficient that they allow a person to understand the essence of the matter and execute the algorithm. In practice, computers act as executors of algorithms. Therefore, an algorithm intended for execution on a computer must be written in a language “understandable” to it; such a formalized language is called programming language.

Program- description of the structure of the algorithm in an algorithmic programming language.

Specifying algorithms using flowcharts has proven to be a very convenient means of depicting algorithms and has become widespread.

Block diagram algorithm - a graphical representation of the algorithm in the form of interconnected ones using arrows (transition lines) and blocks- graphic symbols, each of which corresponds to one step of the algorithm. Inside the block a description of the corresponding action is given.

The table shows the most commonly used symbols.

Symbol name

Designation and example of filling

Explanation

Computational action or sequence of actions

Checking conditions

Modification

Start of the cycle

Predefined process

Calculations by subroutine, standard subroutine

Input Output

I/O in General

Start-stop

Beginning, end of the algorithm, entry and exit to the subroutine

Document

Output of results

Flowchart Symbols

Block " process" is used to denote an action or sequence of actions that changes the meaning, form of presentation or placement of data. To improve the clarity of the diagram, several individual processing blocks can be combined into one block. The presentation of individual operations is quite free.

Block " solution" is used to indicate conditional control transitions. Each "solution" block must identify the question, condition, or comparison it defines.

Block " modification» used to organize cyclic structures. (The word “modification” means “modification, transformation”). A cycle parameter is written inside the block, for which its initial value, boundary condition and step of changing the parameter value are indicated for each repetition.

Block " predefined process" is used to indicate calls to auxiliary algorithms that exist autonomously in the form of some independent modules, and for calls to library routines.

For example, here is a block diagram of the algorithm for finding the maximum of two values: