# Pascal. The concept of an algorithm. Ways to write algorithms. Classification of algorithms by structure. Algorithm Properties

## The concept of an algorithm. Ways to write algorithms. Classification of algorithms by structure. Algorithm Properties

### Contents

Search other websites:

##### 1. What is an algorithm? The definition of the algorithm. Examples of algorithms

Every day a person sets himself different tasks, which he then solves. Some decisions are formed spontaneously, some follow a previously developed plan. In any case, a person seeks to achieve the desired result. In programming, to solve any problem, you first need to develop an algorithm.

Algorithm – an accurate and understandable instruction to the executer to make a sequence of actions aimed at achieving a specified goal or solving a task. A number of requirements are presented to the algorithm. The algorithm should be designed so that its implementation necessarily leads to the desired result.

Algorithm development is a creative process. For the same problem, a different number of algorithms can be developed that solve it. And, on the contrary, for some different types of tasks a generalized algorithm for solving them can be distinguished. The correct development of the algorithm depends on the correct operation of the program. If the complexity of the problem is high, then the execution of the algorithm requires more significant labor and time resources.

An example of an algorithm. Let the student need to write a report and print it on a home printer. A generalized algorithm for performing this work may be, for example, as follows:

1. Familiarize yourself with the necessary materials, literature, etc.
2. Turn on the computer.
4. Type or edit the text of the report.
5. Turn on the printer.
6. Print report.
7. Reread the report again. If errors are found in the report, repeat steps 4-6.

### ⇑

##### 2. Algorithm writing methods

There are three ways to write algorithms:

1. Verbal – this is the case when the algorithm is described in ordinary language (human-readable).
2. Graphic – the case when the algorithm is described using graphic notation. This is the most common way of writing an algorithm, which is indicated in the form of flowcharts.
3. Character – a description of the algorithm using a character set.

### ⇑

##### 3. Graphic way to write an algorithm. Designation on flowcharts

The most common way to write an algorithm is a graphical method in the form of a flowchart. A block diagram is a drawing consisting of geometric shapes (rectangles, parallelepipeds, rhombuses, ovals, etc.) that are connected by directional lines. Geometric figures (blocks) correspond to certain steps of the algorithmic process, and directional lines determine the execution order of blocks.

The geometric designations of the most common blocks are shown in Figure 1.

Figure 1. The geometric designations of the most common blocks that are used in flowcharts

### ⇑

##### 4. Classification of algorithms by structure

The following types of algorithms are distinguished:

• linear algorithm – the case when the blocks of operations are performed sequentially one after another (Figure 2). In such algorithms, each stage of the calculation is reduced to the execution of a sequence of instructions that are executed once;
• branched algorithm. In these algorithms, the course of solving the problem depends on the fulfillment (or not fulfillment) of a certain condition (Figure 3);
• a cyclic algorithm is an algorithm in which one or another part of the calculations is performed repeatedly (Figure 4). The number of repetitions must be finite.

Figure 2. Linear algorithm

Figure 3. Branched algorithm

Figure 4. Loop algorithm

### ⇑

##### 5. Algorithm properties

The following properties are distinguished for the algorithm:

• certainty (accuracy) of the algorithm – the course of solving the problem should be accurate, understandable and exclude the possibility of arbitrary interpretation. The calculation process must be such that it can be repeated;
• mass – the algorithm should be applicable to a number of similar tasks for which the initial conditions change;
• discreteness. This is a partition of the problem into elementary operations to ensure its solution. One and the same problem can be solved in different ways. However, each of the methods breaks down the solution of the problem into several smaller subtasks;
• potency – solving a problem should lead to some result;
• correctness – due to the step-by-step execution of the algorithm, the correct result should be obtained.
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "https://www.bestprog.net/en/2020/07/11/pascal-the-concept-of-an-algorithm-ways-to-write-algorithms-classification-of-algorithms-by-structure-algorithm-properties/", "fetch_time": 1702193288000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2023-50/segments/1700679101282.74/warc/CC-MAIN-20231210060949-20231210090949-00557.warc.gz", "warc_record_offset": 710913071, "warc_record_length": 16134, "token_count": 920, "char_count": 4612, "score": 3.5625, "int_score": 4, "crawl": "CC-MAIN-2023-50", "snapshot_type": "longest", "language": "en", "language_score": 0.9023339748382568, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00007-of-00064.parquet"}