You get a bonus - 1 coin for daily activity. Now you have 1 coin

9.3 Flowcharts Basic algorithmic constructions

Lecture



An algorithm of any complexity can be represented by a combination of three basic structures:

  • following;
  • branching (in full and abbreviated form);
  • cycle (with precondition or postcondition).

The main types of algorithms:

  • Linear;
  • Branching out;
  • Cyclical.

Linear

Linear algorithms in which all actions are performed one after another, regardless of the source data and the results of intermediate calculations. A typical form for a linear algorithm is the sequential execution of commands.

  9.3 Flowcharts Basic algorithmic constructions

Branching out

A branching is an algorithm in which, depending on the source data and the results of intermediate calculations, a choice is made on one of the possible options. Variants (directions of calculations), which can be used to implement the computational process, are called branches . The choice of branch depends on the results of checking some condition. If the condition is satisfied, then one branch is selected, if not, then the other branch. At the end of the branch there should be a special pointer showing the last action. You can, for example, use the words "End of branching."

  9.3 Flowcharts Basic algorithmic constructions

Cyclic

Cyclic is an algorithm in which the result is obtained by repeatedly performing the same operations.

A cycle is a repetitive part of a computational process. There are always four actions in a loop:

  • preparation - setting the initial value to the cycle parameter;
  • basic actions (cycle body) - implementation of necessary calculations;
  • preparing for the next cycle (modification) - changing the cycle parameter;
  • condition check - check the end of cycle condition.

The method of organizing the cycle depends on the condition of the problem. Sometimes the number of repetitions of the cycle is indicated. These are the so-called counter cycles (or arithmetic algorithms) .

Types of cyclic algorithms:

  • Cycle with a precondition . Before executing the loop, the condition for executing the loop is checked. If the condition is true, then the loop is executed. If the condition is false, the cycle ends.
  • Cycle with post-condition . The continuation condition of the cycle is checked already after the cycle body is executed.

The main difference is that in the second case, the cycle is executed at least once, and in the first case, it may turn out that the cycle is not executed at all.

  • A cycle with a specified number of repetitions, when the number of repetitions of the cycle is indicated. These are the so-called counter cycles (or arithmetic cycles).
  • The iteration loop is used when the accuracy of the result calculation is given. In this cycle, at each step (iteration) there is a gradual refinement of the result. In most tasks, the computational process that implements the algorithm is combined, i.e. it contains branching, is cyclic, or iterative.

The main functional elements of the flowcharts of the algorithms in accordance with GOST 19002-89 ESPD

Symbol name Designation and Filling Example Explanation
Process   9.3 Flowcharts Basic algorithmic constructions Computational action or sequence of actions
Decision   9.3 Flowcharts Basic algorithmic constructions Condition check
Modification   9.3 Flowcharts Basic algorithmic constructions Cycle start
Predefined process   9.3 Flowcharts Basic algorithmic constructions Calculation by subroutine, standard subroutine
Output-input   9.3 Flowcharts Basic algorithmic constructions Output-input in general
Start stop   9.3 Flowcharts Basic algorithmic constructions The beginning, the end of the algorithm, the input-output in the subroutine
Document   9.3 Flowcharts Basic algorithmic constructions Printing results


Comments


To leave a comment
If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Informatics

Terms: Informatics