Menu English Ukrainian russian Home

Free technical library for hobbyists and professionals Free technical library


Lecture notes, cheat sheets
Free library / Directory / Lecture notes, cheat sheets

Computer science. Fundamentals of algorithmization and programming (lecture notes)

Lecture notes, cheat sheets

Directory / Lecture notes, cheat sheets

Comments on the article Comments on the article

Table of contents (expand)

Topic 9. Basics of algorithmization and programming

9.1. The concept of an algorithm

An algorithm is a strictly defined and understandable instruction to the performer to perform a sequence of actions aimed at solving the task.

The term "algorithm" comes from the Latin form of the name of the Central Asian mathematician Al-Khwarizmi - Algorithmi. Algorithm is one of the basic concepts of computer science and mathematics.

The executor of the algorithm is some abstract or real (technical, biological or biotechnical) system that is capable of performing the actions prescribed by the algorithm.

To characterize the performer, several concepts are used:

▪ Wednesday;

▪ command system;

▪ basic actions;

▪ refusals.

The environment (or environment) is the "habitat" of the performer.

Any of the executors can execute commands only from some strictly defined list, which is the executor's command system. Applicability conditions are set for each command (in what environment states the command can be executed) and the results of command execution are given.

After calling the command, the executor performs the corresponding elementary action.

An executor may also fail if the command is called when the environment state is invalid for it. Most often, the performer knows nothing about the purpose of the algorithm. He performs all the actions proposed to him, without asking questions "why" and "what for".

In computer science, the universal executor of algorithms is the computer.

The main properties of the algorithms are:

1) understandability for the performer - the performer of the algorithm must know how to execute it;

2) discreteness (discontinuity, separation) - the algorithm should represent the process of solving the problem as a sequential execution of simple (or previously defined) steps (stages);

3) certainty - each rule of the algorithm must be clear, unambiguous and leave no room for arbitrariness. This property ensures the execution of the algorithm mechanically, without requiring any additional instructions or information about the problem being solved;

4) effectiveness (or finiteness) - the algorithm should lead to the solution of the problem in a finite number of steps;

5) mass character - the algorithm for solving the problem is produced in a general form, i.e. it can be applied to a certain class of problems that differ only in the initial data. In this case, the initial data can be selected from a certain area, which is called the area of ​​applicability of the algorithm.

In practice, the following forms of representation of algorithms are most often encountered:

▪ verbal - written in natural language;

▪ graphic - using an image of graphic symbols;

▪ pseudocodes - semi-formalized descriptions of algorithms in some conditional algorithmic language, which include both elements of a programming language and natural language phrases, generally accepted mathematical notations, etc.;

▪ software - texts in programming languages.

The verbal way of writing algorithms is a description of the successive stages of data processing. The algorithm can be given in an arbitrary presentation in natural language. For example, the algorithm for finding the greatest common divisor of two natural numbers can be represented as the following sequence of actions:

1) setting two numbers;

2) if the numbers are equal, then the choice of any of them as an answer and stop, otherwise - the continuation of the algorithm;

3) determining the largest of the numbers;

4) replacement of the larger of the numbers by the difference between the larger and smaller of the numbers;

5) repetition of the algorithm from step 2.

The above algorithm is used for any natural numbers and should lead to the solution of the problem.

The verbal method is not widely used, as it has some disadvantages:

▪ these descriptions are not strictly formalized;

▪ are distinguished by the verbosity of entries;

▪ allow for ambiguity in the interpretation of individual regulations.

The graphic way of presenting algorithms is more compact and visual than the verbal way. With this type of representation, the algorithm is depicted as a sequence of interconnected functional blocks, each of which corresponds to the execution of a certain number of actions.

For graphical representation, the algorithm uses an image in the form of a sequence of interconnected functional blocks, each of which corresponds to the execution of one or more actions. This graphical representation is called a flowchart or flowchart.

In the flowchart, each of the types of actions (input of initial data, calculation of expression values, checking conditions, controlling the repetition of actions, finishing processing, etc.) corresponds to a geometric figure represented as a block symbol. Block symbols are connected by transition lines, which determine the order in which actions are performed.

Pseudocode is a system of notation and rules that is designed to uniformly write algorithms. It occupies an intermediate position between natural and formal languages. On the one hand, pseudocode is similar to ordinary natural language, so algorithms can be written and read in it like plain text. On the other hand, some formal constructions and mathematical symbols are used in pseudocode, due to which the notation of the algorithm approaches the generally accepted mathematical notation.

Pseudocode does not use strict syntactic rules for writing commands that are inherent in formal languages, which makes it easier to write an algorithm at the design stage and makes it possible to use a wider set of commands designed for an abstract executor. However, pseudocode most often contains some constructs inherent in formal languages, which facilitates the transition from writing in pseudocode to writing an algorithm in a formal language. For example, in pseudocode, as well as in formal languages, there are function words, the meaning of which is determined once and for all. They are highlighted in bold in printed text and underlined in handwritten text. There is no single or formal approach to defining pseudocode; therefore, various pseudocodes are used, differing in the set of function words and basic (basic) constructions.

The software form of the representation of algorithms is sometimes characterized by some structures consisting of separate basic (basic) elements. With this approach to algorithms, the study of the basic principles of their design should begin with these basic elements. Their description is carried out using the language of algorithm schemes and the algorithmic language.

9.2. Programming systems

Machine-oriented languages ​​refer to machine-dependent programming languages. The main constructive means of such languages ​​make it possible to take into account the peculiarities of the architecture and principles of operation of a certain computer, that is, they have the same capabilities and requirements for programmers as machine languages. However, unlike the latter, they require prior translation into machine language of the programs compiled with their help.

These types of programming languages ​​can be: autocodes, symbolic coding languages ​​and assemblers.

Machine-independent languages ​​do not require full knowledge of the specifics of computers. With their help, you can write the program in a form that allows its implementation on a computer with various types of machine operations, the binding to which is assigned to the appropriate translator.

The reason for the rapid development and use of high-level programming languages ​​is the rapid growth of computer performance and the chronic shortage of programmers.

An intermediate place between machine-independent and machine-dependent languages ​​is given to the C language. It was created in an attempt to combine the advantages inherent in the languages ​​of both classes. This language has a number of features:

▪ makes maximum use of the capabilities of a specific computing architecture; because of this, C programs are compact and work efficiently;

▪ allows you to make best use of the enormous expressive power of modern high-level languages.

Languages ​​are divided into procedural-oriented and problem-oriented.

Procedurally oriented languages, such as Fortran, Cobol, BASIC, Pascal, are most often used to describe algorithms for solving a wide class of problems.

Domain-oriented languages, in particular RPG, Lisp, APL, GPSS, are used to describe information processing processes in a narrower, specific area.

Object-oriented programming languages ​​allow you to develop software applications for a wide range of diverse tasks that have commonality in the implemented components.

Consider the methods of using programming languages.

Interpretation is operator-by-operator translation and subsequent execution of the translated operator of the source program. There are two main disadvantages of the interpretation method:

1) the interpreting program must be located in the computer memory throughout the entire process of executing the original program. In other words, it must occupy some fixed amount of memory;

2) the process of translation of the same statement is repeated as many times as this command must execute in the program. This leads to a sharp decrease in the performance of the program.

Interpreter translators are quite common because they support dialog mode.

The processes of translation and execution during compilation are separated in time: first, the source program is fully translated into machine language, after which the translated program can be repeatedly executed. For translation by the compilation method, repeated "viewing" of the program being translated is necessary, i.e. compiler compilers are multi-pass. Compilation translation is called an object module, which is the equivalent program in machine code. Before execution, the object module must be processed by a special OS program and converted into a load module.

Translators are also used as interpreters-compilers, which combine the advantages of both translation principles.

9.3. Classification of high-level programming languages

High-level languages ​​are used in machine-independent programming systems. Such programming systems, in comparison with machine-oriented systems, appear to be easier to use.

High-level programming languages ​​are divided into procedural, domain-oriented, and object-oriented.

Procedure-oriented languages ​​are used to write procedures or information processing algorithms for each specific range of tasks. These include:

a) the language Fortran (Fortran), whose name comes from the words Formulae Translation - "formula conversion". Fortran is one of the oldest high-level programming languages. The duration of its existence and use can be explained by the simplicity of the structure of this language;

b) the Basic language, which stands for Beginner's All-purpose Symbolic Instruction Code, which means "multipurpose symbolic instruction code for beginners", was developed in 1964 as a language for teaching programming;

c) the C language (C), used since the 1970s. as a system programming language specifically for writing the UNIX operating system. In the 1980s on the basis of the C language, the C++ language was developed, practically including the C language and supplemented with object-oriented programming tools;

d) the Pascal language, which is named after the French scientist B. Pascal, began to be used from 1968-1971. N. Wirth. At its inception, Pascal was used for teaching programming, but over time it has become widely used for developing software tools in professional programming.

Domain-oriented languages ​​are used to solve whole classes of new problems that have arisen in connection with the constant expansion of the field of application of computer technology:

a) the Lisp language (Lisp - List Information Symbol Processing), which was invented in 1962 by J. McCarthy. Initially, it was used as a tool for working with character strings. Lisp is used in expert systems, analytical computing systems, etc.;

b) the Prolog language (Prolog - Programming in Logic), used for logical programming in artificial intelligence systems.

Object-oriented languages ​​are developing and at the moment. Most of these languages ​​are versions of procedural and problematic languages, but programming with the languages ​​of this group is more visual and easier. The most commonly used languages ​​are:

a) Visual Basic (~ Basic);

b) Delphi (~Pascal);

c) Visual Fortran (~ Fortran);

r) C++ (~C);

e) Prolog++ (~ Prolog).

9.4. VBA system

The VBA system is a subset of VB and includes the VB application builder, its data structures, and control structures that enable you to create custom data types. Like VB, VBA is an event-driven visual programming system. It has the ability to create forms with a standard set of controls and write procedures that handle events that occur during certain actions of the system and the end user. It also allows you to use ActiveX controls and automation. The VBA system is a complete programming system, but it does not have the full range of features that the latest version of VB has.

Programming in the VBA environment has a number of features. In particular, you cannot create a project in it independently of these applications.

Because VBA is a visual system, the programmer is able to create the visible part of the application, which is the basis of the program-user interface. Through this interface, the user interacts with the program. Based on the principles of the object-oriented approach, which is implemented in VBA in relation to applications running under Windows, a programming interface is being developed.

A characteristic of these applications is that there are many objects on the screen at any time (windows, buttons, menus, text and dialog boxes, scroll bars). Given the program algorithm, the user has a certain freedom of choice regarding the use of these objects, i.e., he can click on a button, move an object, enter data into a window, etc. When creating a program, the programmer should not limit the actions of the user, he must develop a program that correctly responds to any user action, even incorrect.

For any object, a number of possible events are defined. Some events are triggered by user actions, such as a single or double mouse click, dragging an object, pressing a keyboard key, and so on. Some events occur as a result of other events: a window opens or closes, a control becomes active or becomes inactive.

Any of the events manifests itself in certain actions of the program, and the types of possible actions can be divided into two groups. The actions of the first group are the result of object properties that are set from some standard list of properties that are set by the VBA programming system and the Windows system itself, for example, minimizing a window after clicking the Minimize button. The second group of actions on events can be defined only by the programmer. For any possible event, the response is provided by creating a VBA procedure. Theoretically, it is possible to create a procedure for each event, but in practice, the programmer fills in the procedure code only for the events of interest in the given program.

VBA objects are functional, that is, they act in a certain way and are able to respond to specific situations. The appearance of an object and its behavior affect its properties, and the methods of an object determine the functions that the object is capable of performing.

Member properties are properties that define nested objects.

Objects are capable of responding to events - initiated by the user and generated by the system. Events initiated by the user appear, for example, when a key is pressed, when a mouse button is clicked. Based on this, any user action can lead to a whole set of events. Events generated by the system appear automatically in the case provided by the computer software.

9.5. VBA programming language

The VBA programming language is designed for writing program code. It has its own alphabet, which includes:

▪ lowercase and uppercase letters of the Latin alphabet (A, B....,Z,a,b....,z);

▪ lowercase and uppercase letters of the Cyrillic alphabet (А-Я, а-я);

▪ non-displayable characters used to separate lexemes (lexical units) from each other;

▪ special characters involved in constructing language constructs: +-*?^=><[]():{}' &©;

▪ numbers from 0 to 9;

▪ underscore "_";

▪ composite characters perceived as one character: =, <>.

A token is a unit of program text that has a specific meaning to the compiler and cannot be further broken down.

VBA program code is a sequence of tokens written in accordance with accepted syntactic rules that implements the desired semantic construction.

An identifier is a sequence of letters, numbers, and underscores.

The VBA system defines some restrictions that are placed on names:

1) the name should start with a letter;

2) the name must not include dots, spaces, separating characters, operation signs, special characters;

3) the name must be unique and not the same as VBA reserved words or other names;

4) name length should not exceed 255 characters;

5) when composing names, it is necessary to follow style conventions;

6) the identifier must clearly reflect the purpose of the variable for understanding the program;

7) it is better to use lowercase letters in names; if the names include several names, they must be separated from each other by underlining or a new word must be started with a capital letter;

8) names of constants should be composed of capital letters;

9) the name of an identifier must begin with a special character indicating the type of data associated with this identifier.

Variables are objects that are designed to store data. Before using variables in a program, they must be declared (declared). The correct choice of variable type ensures efficient use of computer memory.

String variables can be of variable or fixed length.

Objects whose values ​​do not change and cannot be changed during program execution are called constants. They are divided into named and unnamed.

Enums are used to declare a group of constants under a common name, and they can only be declared in the global declaration section of a module or form.

Variables are divided into two types - simple and structural variables. Arrays are one-dimensional and multidimensional.

After the declaration, the value of the variable can be arbitrary. An assignment operator is used to assign a value to a variable.

Mathematical operations are used to write a formula, which is a program statement that contains numbers, variables, operators, and keywords.

Relational operations can result in a value, and there are only two resulting values: true and false.

Logical operations are used in logical expressions, this happens when there are several selection conditions in relational operations.

String operations are concatenation operations that combine the values ​​of two or more string variables or string constants. The result of such an operation is a longer string composed of the original strings.

Author: Kozlova I.S.

<< Back: Specialized professionally oriented software tools (Information systems of organizational and economic management. Modern information technologies in systems of organizational and economic management. Information systems of organizational and economic management. Office activities in systems of organizational and economic management. Organizational, technical and peripheral means of information systems. The concept of business graphics. Use of graphics in business. Business graphics program MS GRAPH. General characteristics of the technology for creating application software. Application software. Technology of system design of software. Modern methods and tools for developing application software)

>> Forward: Fundamentals of information security (Information protection as a pattern of development of computer systems. Objects and elements of protection in computer data processing systems. Means of identification and access control to information. Cryptographic method of information protection. Computer viruses. Anti-virus programs. Protection of software products. Ensuring data security on an offline computer. Security data in an interactive environment)

We recommend interesting articles Section Lecture notes, cheat sheets:

Nervous diseases. Crib

Insurance law. Crib

Financial right. Crib

See other articles Section Lecture notes, cheat sheets.

Read and write useful comments on this article.

<< Back

Latest news of science and technology, new electronics:

The existence of an entropy rule for quantum entanglement has been proven 09.05.2024

Quantum mechanics continues to amaze us with its mysterious phenomena and unexpected discoveries. Recently, Bartosz Regula from the RIKEN Center for Quantum Computing and Ludovico Lamy from the University of Amsterdam presented a new discovery that concerns quantum entanglement and its relation to entropy. Quantum entanglement plays an important role in modern quantum information science and technology. However, the complexity of its structure makes understanding and managing it challenging. Regulus and Lamy's discovery shows that quantum entanglement follows an entropy rule similar to that for classical systems. This discovery opens new perspectives in the field of quantum information science and technology, deepening our understanding of quantum entanglement and its connection to thermodynamics. The results of the study indicate the possibility of reversibility of entanglement transformations, which could greatly simplify their use in various quantum technologies. Opening a new rule ... >>

Mini air conditioner Sony Reon Pocket 5 09.05.2024

Summer is a time for relaxation and travel, but often the heat can turn this time into an unbearable torment. Meet a new product from Sony - the Reon Pocket 5 mini-air conditioner, which promises to make summer more comfortable for its users. Sony has introduced a unique device - the Reon Pocket 5 mini-conditioner, which provides body cooling on hot days. With it, users can enjoy coolness anytime, anywhere by simply wearing it around their neck. This mini air conditioner is equipped with automatic adjustment of operating modes, as well as temperature and humidity sensors. Thanks to innovative technologies, Reon Pocket 5 adjusts its operation depending on the user's activity and environmental conditions. Users can easily adjust the temperature using a dedicated mobile app connected via Bluetooth. Additionally, specially designed T-shirts and shorts are available for convenience, to which a mini air conditioner can be attached. The device can oh ... >>

Energy from space for Starship 08.05.2024

Producing solar energy in space is becoming more feasible with the advent of new technologies and the development of space programs. The head of the startup Virtus Solis shared his vision of using SpaceX's Starship to create orbital power plants capable of powering the Earth. Startup Virtus Solis has unveiled an ambitious project to create orbital power plants using SpaceX's Starship. This idea could significantly change the field of solar energy production, making it more accessible and cheaper. The core of the startup's plan is to reduce the cost of launching satellites into space using Starship. This technological breakthrough is expected to make solar energy production in space more competitive with traditional energy sources. Virtual Solis plans to build large photovoltaic panels in orbit, using Starship to deliver the necessary equipment. However, one of the key challenges ... >>

Random news from the Archive

Fresh water from the seabed 03.03.2004

In the Mediterranean Sea near the French city of Menton, 800 meters from the coast, at a depth of 36 meters, a source of fresh water was found gushing from the seabed.

The existence of such underwater keys was reported by ancient authors. Now there are more than a thousand such sources all over the world. But the source near Menton is interesting in that it was first exploited to supply the city with drinking water.

For fear of disturbing the source, they did not drill it and turn it into a well, they simply put an anchored metal cap with a diameter of two meters and a height of ten, connected with a flexible hose to the surface, above it. Fresh water, as lighter, rises into the cap.

The water pressure at depth is so great that pumps are not needed. Above the surface of the sea, it beats like a fountain, one hundred liters per second. But under the cap, sea water seeps in a small amount, so a weakly mineralized drink is obtained (less than a gram of sea salts per liter). Such water is suitable for irrigating plants, but it will still be desalinated for drinking.

Meanwhile, a thousand times more powerful freshwater source was found underwater off the coast of Syria. The issue of its arrangement with the same system is being considered.

Other interesting news:

▪ Cultural peculiarities of perception appear by the age of two

▪ Nissan pavilion with a demonstration of green technologies

▪ Transmitting antennae the size of a fingernail

▪ WiFi MP3 player

▪ Camera in watch

News feed of science and technology, new electronics

 

Interesting materials of the Free Technical Library:

▪ website section Television. Article selection

▪ article Where, where have you gone, / My golden days of spring? Popular expression

▪ article Which fish lay their eggs for rearing other fish, like cuckoos? Detailed answer

▪ article Blood knot. Travel Tips

▪ article External microphone powered by a communication line. Encyclopedia of radio electronics and electrical engineering

▪ article Wonderful bottle. Focus Secret

Leave your comment on this article:

Name:


Email (optional):


A comment:





All languages ​​of this page

Home page | Library | Articles | Website map | Site Reviews

www.diagram.com.ua

www.diagram.com.ua
2000-2024