Almost everything in our world is subject to some kind of laws and rules. Modern science does not stand still, thanks to which mankind knows a lot of formulas and algorithms, following which it is possible to calculate and recreate many actions and structures created by nature, and bring to life ideas invented by man.
In this article we will look at the basic concepts of the algorithm.
Algorithm is a concept that appeared in the 12th century. The word “algorithm” itself comes from the Latin interpretation of the name of the famous Middle Eastern mathematician Muhammad al-Khwarizmi, who wrote the book “On Indian Calculus.” This book describes how to correctly write natural numbers using Arabic numerals, and provides a description of the algorithm for working with a column over such numbers.
In the 12th century, the book “On Indian Accounting” was translated into Latin, and it was then that this definition appeared.
Creating an algorithm requires creativity, so only a living creature can create a new list of sequential actions. But to carry out already existing instructions, you don’t need to have imagination; even soulless technology can handle this.
An excellent example of following instructions exactly is an empty microwave oven that continues to operate despite there being no food inside.
A subject or object that does not need to understand the essence of the algorithm is called a formal executor. A person can also become a formal executor, but if a particular action is unprofitable, a thinking executor can do everything in his own way. Therefore, the main performers are computers, microwave ovens, telephones and other equipment. The concept of algorithm in computer science is of the most importance. Each algorithm is compiled with a specific subject in mind, taking into account acceptable actions. Those objects to which the subject can apply instructions constitute the executor's environment.
Almost everything in our world is subject to some kind of laws and rules. Modern science does not stand still, thanks to which mankind knows a lot of formulas and algorithms, following which it is possible to calculate and recreate many actions and creations of nature and bring to life ideas invented by man. In this article we will look at the basic concepts of the algorithm.
Most of the actions that we perform during our lives require compliance with a number of rules. The quality and result of completing the tasks assigned to him depends on how correct a person has an idea of what, how and in what sequence he should do. Since childhood, parents have been trying to develop an algorithm for their child’s basic actions, for example: waking up, making the bed, washing and brushing teeth, doing exercises, having breakfast, etc., a list that a person carries out all his life in the morning can also be considered a kind of algorithm.
Which method will be used depends on several factors: the complexity of the problem, how detailed the process of solving the problem needs to be, etc.
A graphical algorithm is a concept that implies the decomposition of actions that need to be performed to solve a certain problem into certain geometric shapes.
They are not depicted haphazardly. In order for anyone to understand them, block diagrams and Nussi-Schneiderman structure diagrams are most often used.
Also, block diagrams are depicted in accordance with GOST-19701-90 and GOST-19.003-80.
Graphic figures used in the algorithm are divided into:
Basic. Basic images are used to indicate the operations needed to process data when solving a problem.
Auxiliary. Auxiliary images are needed to indicate individual, not the most important, elements of solving a problem.
In a graphical algorithm, the blocks used to represent data are called blocks.
All blocks go in the sequence “from top to bottom” and “from left to right” - this is the correct direction of flow. With the correct sequence, the lines connecting the blocks do not show direction. In other cases, the direction of the lines is indicated using arrows.
A correct algorithm scheme should not have more than one output from processing blocks and less than two outputs from blocks responsible for checking the fulfillment of conditions.
How to build an algorithm correctly?
The structure of the algorithm, as mentioned above, must be built in accordance with GOST, otherwise it will not be understandable and accessible to others.
The general recording methodology includes the following points:
A name that will make it clear what problem can be solved using this scheme.
Each algorithm must have a clearly defined beginning and end.
Algorithms must clearly and clearly describe all data, both input and output.
When compiling an algorithm, you should note the actions that will allow you to perform the actions necessary to solve the problem on the selected data. An example of the algorithm:
Correct construction of the circuit will greatly facilitate the calculation of algorithms.
A horizontal oval is the beginning and the end (a sign of completion).
A horizontal rectangle is a calculation or other action (process sign).
Horizontal parallelogram - input or output (data sign).
A horizontally located rhombus is a condition check (solution sign).
An elongated, horizontally located hexagon is a modification (a sign of preparation).
The algorithm models are presented in the figure below.
Formula-verbal version of constructing an algorithm.
Formula-verbal algorithms are written in free form, in the professional language of the field to which the problem relates. Description of actions in this way is carried out using words and formulas.
In the computer field, everything is based on algorithms. Without clear instructions entered in the form of a special code, not a single technique or program will work. In computer science lessons, students are taught the basic concepts of algorithms, taught how to use them and how to create them themselves.
The creation and use of algorithms in computer science is a more creative process than, for example, following instructions for solving a problem in mathematics.
There is also a special program called “Algorithm”, which helps people who are not familiar with programming to create their own programs. Such a resource can become an indispensable assistant for those who are taking their first steps in computer science and want to create their own games or any other programs.
On the other hand, any program is an algorithm. But if the algorithm contains only actions that need to be performed by inserting your data, then the program already contains ready-made data. Another difference is that a program can be patented and is proprietary, but an algorithm cannot. An algorithm is a broader concept than a program.
In this article, we examined the concept of an algorithm and its types, and learned how to correctly write graphic diagrams.
CONCEPT OF ALGORITHM.
PROPERTIES OF THE ALGORITHM. TYPES OF ALGORITHMS. METHODS OF DESCRIBING ALGORITHMS
An algorithm is a precise and understandable instruction to a performer to perform a sequence of actions aimed at solving a given problem. The word “algorithm” comes from the name of the mathematician Al Khorezmi, who formulated the rules for performing arithmetic operations. Initially, an algorithm meant only the rules for performing four arithmetic operations on numbers. Later, this concept began to be used in general to denote the sequence of actions leading to the solution of any given task. When talking about the algorithm of the computational process, it is necessary to understand that the objects to which the algorithm was applied are data. An algorithm for solving a computational problem is a set of rules for converting source data into results. Main
Indicates the presence of such initial data for which the computational process implemented according to a given algorithm must stop after a finite number of steps and produce the desired result;
mass character. This property implies that the algorithm should be suitable for solving all problems of a given type;
Block diagram is a graphical representation of the logical structure of an algorithm, in which each stage of the information processing process is represented in the form of geometric symbols (blocks) that have a certain configuration depending on the nature of the operations performed. The list of symbols, their names, the functions they display, shape and dimensions are determined by GOSTs.
With all the variety of algorithms for solving problems, three main types of computational processes can be distinguished:
Linear is a computational process in which all stages of solving a problem are performed in the natural order of recording these stages.
Branching is a computational process in which the choice of direction for processing information depends on the initial or intermediate data (on the results of checking the fulfillment of any logical condition).
A cycle is a section of calculations that is repeated many times. A computational process containing one or more cycles is called cyclical .
Based on the number of executions, cycles are divided into cycles with a certain (predetermined) number of repetitions and cycles with an indefinite number of repetitions. The number of repetitions of the latter depends on the satisfaction of some condition specifying the need to execute the cycle. In this case, the condition can be checked at the beginning of the cycle - then we are talking about a cycle with a precondition, or at the end - then it is a cycle with a postcondition.
Algorithm-
-a system of precise and understandable instructions, a defined sequence of elementary operations on initial data, the implementation of which ensures the solution of problems of this type. Algorithm properties:
-discreteness- the sequence of problem solving (process) must be divided into a sequence of individual steps.
-clarity- the algorithm must be understandable to the performer. In this regard, the algorithm must be developed with a focus on the specific performer, i.e. The algorithm can include commands from the command systems of a given executor.
-determinism- being understandable, the algorithm should not contain commands whose meaning can be perceived ambiguously. Violation of these requirements by the compilers of algorithms leads to the fact that the same program, when executed by different executors, does not produce the same results.
-mass character- suitability of the algorithm for solving problems of a certain class.
Ways to write the algorithm:
-verbal– natural language method.
-graphic-description of the algorithm using diagrams.
The process of executing operations or groups of operations
input of initial data, output of results
Decision - choice of direction of execution
Modification is the execution of operations that change commands or groups of commands that change programs.
Line connectors on one page.
Interpage connectors.
-programming language– convenient for entering into a computer.
-pseudocode is a language that uses the structure and syntax of a fairly formalized language and at the same time allows for constructions of natures. Language.
Types of algorithms and basic principles for composing algorithms.
-Linear– an algorithm in which commands are executed sequentially one after another in the order of their natural occurrence, regardless of any conditions. S1, s2, S3…Sn
-branching (branching)- this is a process in which its implementation occurs in one of several predetermined directions, depending on the initial data or intermediate results.
Full conditional construction (full branching)
· Incomplete conditional construction
· Select from several
-cyclical– an algorithm in which a sequence can be executed more than once.
Loop with parameter
· Loop with precondition. It may never be executed. The body of the loop must contain an operator that changes the value of a variable included in block Q.
· Loop with postcondition. Executes at least once.
Basic principles of algorithmization:
1. Identify the source data, results and assign names to them.
2. Problem solving method.
3. Divide the method of solving problems into stages.
4. With a graph representation of the algorithm, each stage is in the form of a corresponding block - a diagram of the algorithm and the order of their execution is indicated by communication lines.
5. In the resulting scheme for any calculation option.
Provide for the issuance of results or messages about their absence.
Provide opportunities after performing any operation to somehow move to the end block.
40.Basic algorithmic structures
We have already looked at the basic concepts of programming and are moving a little closer to the point (but only closer, we will program later).
Let's look at the main structures of the algorithms, and there are six of them:
· Following. This is a sequence of blocks (or groups of blocks) of an algorithm. In the program, following is presented in the form of sequential execution of operations
·
Branching. This algorithmic structure is used when, depending on the condition, it is necessary to perform one or another action
·
Bypass. This structure is a special case of branching, when there is no action in one of the branches.
·
Multiple choice. This structure is a generalization of branching, where it is necessary to perform one of several actions depending on the value of the variable A.
Before we start writing super programs, let's figure out what a program is? A program is a specific algorithm that your computer must execute.
Well, now the main question: What is an algorithm?
I will not reinvent the wheel, but will simply list the properties of the algorithm that have been known for many years.
Thus, Algorithm- this is a clear and precise instruction to the performer to perform a final sequence of steps leading from the initial data to the desired result.
Imagine that I have to cut an orange with a knife. To perform this action I need an algorithm.
Algorithm example:
Start
take out the knife
cut an orange (It’s an orange, not any other fruit. ACCURACY is responsible for this)
eat an orange
end
Algorithm example:
Start
take out the knife
UNTIL the oranges are gone
cut an orange
eat all the oranges
end
Algorithm example:
Start
take out the knife
IF the knife is dull, sharpen it
cut an orange
eat an orange
end
That's all. In the next lesson we will look at the structure of a program in Pascal.
There is no single “true” definition of the concept “algorithm”.
“An algorithm is a finite set of rules that defines a sequence of operations to solve a specific set of problems and has five important features: finiteness, certainty, input, output, efficiency.” (D. E. Knuth)
“An algorithm is any system of calculations performed according to strictly defined rules, which after a certain number of steps obviously leads to the solution of the problem.” (A. Kolmogorov)
“An algorithm is a precise prescription that defines a computational process that goes from varying initial data to the desired result.” (A. Markov)
“An algorithm is a precise prescription for performing in a certain order a certain system of operations leading to the solution of all problems of a given type.” (Philosophical Dictionary / Edited by M. M. Rosenthal)
“An algorithm is a strictly deterministic sequence of actions that describes the process of transforming an object from the initial state to the final state, written using commands understandable to the performer.” (Nikolai Dmitrievich Ugrinovich, textbook “Informatics and information technology”)
“An algorithm is a sequence of actions aimed at obtaining a certain result in a finite number of steps.”
“An algorithm is an unambiguous, accessible and briefly (conventional concepts - stage names) described sequence of procedures for reproducing a process with a result determined by the task of the algorithm under given initial conditions. The universality (or specialization) of an algorithm is determined by the applicability and reliability of this algorithm for solving non-standard problems.”
“An algorithm is clear and precise instructions to the performer to take a finite number of steps aimed at solving a given problem.”
“An algorithm is a certain finite set of operations designed for a specific performer, as a result of which, after a certain number of steps, a given goal can be achieved or a problem of a certain type can be solved.”
“An algorithm is a sequence of actions that either leads to a solution to a problem or explains why this solution cannot be obtained.”
“An algorithm is an exact, unambiguous, finite sequence of actions that a user must perform to achieve a specific goal or to solve a specific task or group of tasks.”
“An algorithm is a precise prescription that specifies a computational (algorithmic) process, starting with an arbitrary initial data and aimed at obtaining a result completely determined by this initial data.”
Various definitions of an algorithm, either explicitly or implicitly, contain the following series of general requirements:
Main types of algorithms:
1)Applied Algorithms - designed to solve certain applied problems.
An algorithm is considered correct if it meets the requirements of the task (for example, it gives a physically plausible result. An algorithm (program) contains errors if for some initial data it gives incorrect results, failures, failures, or does not give any results at all.
2)Recursive Algorithms - algorithms that call themselves until some return condition is reached.
3) Starting from the end of the 20th - beginning of the 21st century, they have been actively developing parallel algorithms - designed for computers capable of performing several operations simultaneously.
The algorithm can be written in words and depicted schematically. Usually, at first (at the level of the idea), the algorithm is described in words, but as it approaches implementation, it acquires more and more formal outlines and formulation in a language understandable to the performer (for example, machine code). For example, flowcharts are used to describe an algorithm. Another description option, independent of the programming language, is pseudocode.