Linear algorithms - diagram structure and calculation

click fraud protection

daily life of every person is to deal with a huge number of problems of varying difficulty at work or while studying.Some tasks are so simple, that in their implementation we are doing certain actions automatically, without even thinking.The solution to any problem, even the most simple, usually carried out sequentially in a few steps.Such a sequence is called for solving algorithm.Today we look at what a linear algorithms, as portrayed by their structure, how is their decision and programming.

algorithmic language

This concept is the exact prescription for the artist to make a sequence of actions, which is directed to the solution of this problem.

This language is a means of describing algorithms that are usually focused on the user.

Speaking in a computer language, as indicated by the exact prescription, defining a computational process.It, in turn, leads from the initial data that range, to the original result.

Development of algorithm - is quite complicated and time-consuming process.It is a technique of drawing up (design) of the sequence of actions targeting to solve problems with a computer.

Properties algorithm

Among the properties of isolated:

  • limb - is the completion of the entire algorithm for determining a finite number of steps (steps);
  • certainty (unambiguous) - is the only interpretation of the rules for the implementation of actions, as well as procedures for their implementation;
  • performance - the desired results for any finite number of steps;
  • clear - instructions must be clear to the executor;
  • mass - algorithms should be able to solve a class of problems specific to the general formulation of the problem.

linear algorithms.Computer Class 9

We have reviewed the definitions and properties of the concept.Now let's talk about his species:

  • line;
  • branching;
  • the cycle.

We are interested in linear algorithms.What are they?They contain commands to be executed one after the other in a clear sequence.

linear structure of the algorithm can be expressed in verbal and graphic form.

give an example, written in words.So the task: Collect the school.Solution:

  • Home.
  • Stand.
  • Do exercises.
  • wash.
  • Get dressed.
  • breakfast.
  • Collect portfolio.
  • End.

graphical form predsatvlyat above process is as follows:

linear algorithm in block diagram form

block diagram is an exemplary illustration of the algorithm, in which each separate phase is represented by blocks represented in a variety of geometric shapes.In addition, the connection between the phases (in other words, the sequence of phased implementation) is indicated by the arrows that connect the shapes (blocks).Each unit is accompanied by the inscription.For typical actions in a linear algorithm, the following geometric shapes:

  • unit start-end algorithm.On the block is the inscription "start" and "end".
  • Block "input-output".This is depicted in block form of a parallelogram.He placed the following inscription: "input", "output", "print".Also it is a list or input, respectively output variables.
  • arithmetic unit, or block decisions.It corresponds to a rectangle.On the block must be the inscription: "operation", "group operations".

Here with such block diagrams depicted solution of linear algorithms.Next, let's talk about the features of assigning values.

Linear computational algorithms

basic elementary action in the computational algorithms - this assignment variables definite value.In the case where the constant value determined by the shape of its recording receive a specific variable value solely by the assignment.This may be accomplished by two methods: using the command assignment;with the command input.

example of solving a linear algorithm

give an example to describe the rules of the division of fractions with a linear algorithm that school textbooks have the content:

  • numerator 1 must be multiplied by the denominator 2;
  • denominator 1 should be multiplied by the numerator 2;
  • want to record a fraction, the numerator of which has the result of the implementation of paragraph 1, and the denominator - the result of a 2 points.The algebraic form of this rule is as follows:

a / b: a / d = (a * d) / (b * d) = m / n.

So, build a computer algorithm for dividing fractions.To avoid confusion, we use the variables are the same notation as in the formula, which has been specified above.a, b, c, d- original data as integer variables.The result will be integer values.The decision on the algorithmic language is as follows:

ALG division of fractions

early

intact a, b, c, d, m, n

enter a, b, c, d

m: =and * d

n: = b * a

conclusion m, n

con

Graphic format solutions

scheme linear algorithm described above is as follows:

Team value assignment has the following format:

variable: = expression.

sign "=" is read as assigned.

assignment - a team that is needed to perform the computer following:

  • expression evaluation;
  • variable assignment of the value.

above algorithm contains two teams as the assignment.In the flowchart command assignment should be recorded in a rectangle, which is called the computing unit.

As described linear algorithms, there is no particular need for mandatory compliance with strict rules when writing expressions.You can record them using the usual mathematical form.It is not a strict programming language syntax.

In this example, the algorithm is also a command input:

Enter a, b, c, d.

team entered in the block diagram is recorded in the parallelogram, ie input-output unit.When executing this command, the processor interrupts until the user will carry out certain actions.Namely, the user needs to input device (keyboard) type input variables (their values) and press Enter, which acts as the Enter key.It is important that values ​​are entered in the same order as in the list enter the appropriate variables.

linear algorithm.Its programming

As mentioned earlier in this article, the linear programs can include such operators:

  • assignment;
  • input;
  • conclusion.

That is, using the above operators to linear programming algorithms.

So, the assignment operator in the programming language is written as:

LET A = B, where A - variable in - expression.For example, A = Y + 20.

entry operator has the following form:

INPUT, for example: INPUT With

operator output data values ​​stored in this form:

PRINT.For example PRINT AS

give a simple example.We need to write a program that will find the amount of input from the keyboard of numbers A and B.

programming language we get a program, the text of which is shown below.

operators input, output in the programming language Pascal

Pascal does not allocate special operators that indicate the input or output operations that use linear algorithms.The programs of exchange of information by using built-in procedures.Since there is no need for a preliminary description of the standard procedure, it is available for each program, containing a reference to it.It is also the name referred to the procedure does not appear any keyword.

When entering data using such statements to refer to the standard procedure of data entry, which is already built into the program.

Read (A, B, C), where A, B, C - variables that must be entered in the memory for remembering.

Readlnn (x1, y, x2) - When finished, the cursor jumps to the beginning of a new line.

Readlnn;- Indicates the waiting press «Enter».Usually this operator is inserted in the text before the final «End», to keep the results of the program on the screen contents.

Displays monitor data by using these operators:

Write (A, B, C) - by specifying the values ​​of A, B, C on the same line, the cursor does not leave the current line.

Writeln (z, y, z2) - finishing the output values, the cursor is in this position will move to a new line.

Writeln;- Indicates the omission of one line and the transition to a new beginning.

That through such simple statements and carried out input and output of data in Pascal.