Last Updated:

What are algorithms for? Basic programming algorithms

Every programmer knows the importance of using algorithms. In this article, we're going to talk about what an algorithm is and what characteristics it has. And most importantly, we'll make a list of algorithms that are widely used in programming and will therefore be useful for the programmer.

Algorithm – what is it?

Informally speaking, an algorithm can be called any correctly defined computational procedure, when a quantity or set of quantities is fed to the input, and the result of the execution is an output value or a set of values. We can say that an algorithm is a certain sequence of computational steps, due to which the input data is converted into output.

You also need to understand that the algorithm as a sequence of steps allows you to solve a specific problem and must:

1. Work for a finite amount of time. If the algorithm is not able to deal with the problem in a finite amount of time, we can say that this algorithm is useless.

2. Have clearly defined instructions. Any step of the algorithm must be precisely defined. At the same time, his instructions should be unambiguous for any case.

3. Be usable. The point is that an algorithm must be able to solve the problem that it was created to solve.

Today, algorithms are used both in computer science and programming, and in mathematics. By the way, the earliest mathematical algorithms are called decomposition into simple factors and extraction of the square root - they were used in ancient Babylon as early as 1600 BC. e. But we will not go far into the past, but consider, as promised, the main programming algorithms for today.

Sorting algorithms (pyramidal, fast, merge)

Sorting algorithms

Which sorting algorithm is considered the best? There's no definitive answer here, because it all depends on your preferences and the tasks you set. Let's look at each of the algorithms:

1. Merge sorting. The most important algorithm today. Based on the principle of comparing elements and uses the "divide and conquer" approach, allowing you to more effectively solve problems that were once solved during the O (n^2) time. Merge sorting was invented by mathematician John von Neumann back in 1945.

2. Quicksort. This is a different approach to sorting. Here the algorithm is based on both in-place partitioning and the principle of "divide and conquer". But this sorting is unstable, which is its problem. But the algorithm is effective at sorting arrays in RAM.

3. Pyramidal sorting. An in-place algorithm that uses a priority queue (due to this queue, the time of data retrieval is reduced).

It is believed that the above algorithms are better if we compare them with others, for example, sorting with a bubble. You can say that it is thanks to sorting algorithms that we today have artificial intelligence, data mining and even the Internet.

Fourier transform. Fast Fourier transform

Fourier transform

Electronic computing devices use algorithms to function, including the Fourier transform algorithm. And the phone, and the smartphone, and the computer, and the router, and the Internet - all this can not work without algorithms to function, remember this.

Dijkstra's algorithm

Dijkstra's algorithm

Without this algorithm, again, the same Internet will not be able to work efficiently. It solves problems in which the problem is represented as a graph that provides a search for the shortest path between 2 nodes. Even today, when we have better solutions, programmers still use the search for the shortest path when it comes to systems that require increased stability.

RSA Algorithm

This algorithm came to us from cryptography. It made cryptography accessible to everyone, predetermining its future. In general, the RSA algorithm is made to solve a simple problem with an unobvious solution. It allows you to share public keys between end users and independent platforms in such a way that encryption can be applied.

Secure Hashing Algorithm

Well, it's not really an algorithm. Rather, it can be called a family of cryptographic hash functions (SHA-1, SHA-2, etc.) that are developed in the United States and are critical to the world. Antivirus, email, app stores, browsers, etc. - all of this uses secure hashing algorithms. (in fact, the hash is the result of their work). The algorithm is needed to determine whether you managed to download what you wanted, and also whether you were not subjected to phishing or attack "man in the middle".

Relationship Analysis

Relationship Analysis

The idea of a link analysis algorithm is simple. For example, you can easily represent a graph in the form of a matrix, which will reduce the problem to the problem of the level of self-importance of each node. This approach to the structure of the graph will allow us to assess the relative importance of each object that is included in the system.

The algorithm was created back in 1976 and is used today when ranking pages in the process of searching on Google, when generating a news feed, when compiling a list of possible friends on Facebook, when working with contacts on LinkedIn and in many other cases. Any of these services works with various objects and parameters and objects, but the mathematics itself does not really change.

Proportional-integral-differentiating algorithm

Proportional-integral-differentiating algorithm

Have you used a car, an airplane, a cellular connection? Have you seen a robot in the works? In all these cases, you can say that you have seen this algorithm in action.

A proportional-integral-differentiating algorithm typically uses a closed feedback mechanism for the control loop. This is necessary to minimize error between the actual output signal and the desired output signal. The algorithm is used where it is necessary to create a system for signal processing or for controlling hydraulic, mechanical and thermal mechanisms of an automated type.

Data compression algorithms

It is difficult to say which algorithm for compression is most important, because depending on the tasks it can vary from zip to mp3 or from JPEG to MPEG-2. But these algorithms are important for almost all areas of activity.

A compression algorithm isn't just another archived document, it lets you compress data on a webpage when it's downloaded to your computer. Or it's used in databases, video, music, cloud computing. Essentially, data compression algorithms make systems cheaper and more efficient.

Random number generation algorithm

Random number generation algorithm

There really isn't a "real" random number generator, and we're already talked about itBut we have pseudo-random number generators that do a great job of doing this. They have an extended variability of use: software applications in programming, cryptography, hashing algorithms, video games, artificial intelligence, tests in program development, etc.