What is an algorithm

An algorithm is a sequence of instructions or commands carried out in a systematic manner with the aim of solving a problem or performing a task .The word “algorithm” refers to the Arab mathematician Al Khwarizmi , who lived in the 9th century, and described rules for mathematical equations.

Algorithms are like a cake recipe: a sequence of actions that must be executed so that the final objective — the finished cake — is achieved.Algorithms are applied to simple everyday tasks and also to complex computer programs that identify consumer behavior on the internet.

All the functions of computers, smartphones and tablets , for example, are the result of algorithms. These machines can perform billions of commands in just a few seconds.

Algorithm Examples

Algorithms are also used in computer programming and on the internet, especially by search engines and social networks.

Algorithms in search engines ( Google )

One of the most remembered examples is the Google search engine algorithm , which performs several operations to organize the way search results appear to the user.

When a user searches on Google for a keyword, such as “what is democracy”, the order of the results shown depends on several calculations that the algorithm performed to place them in that position.

These calculations are based on several variables, such as the quality and currency of the content, the quality of the website where the content is located, and how long people usually spend on that page.

Google ‘s algorithm is quite complex and is updated from time to time to offer a better experience and present the best results to users.

Algorithms in social networks

Social networks are also programmed with complex algorithms. Facebook , Instagram and Twitter feeds , for example, show posts and ads based on user behavior.

This means that not all of your friends’ posts will appear in your feed . The algorithms of these social networks select the ones that make the most sense based on your preferences.

Facebook ‘s algorithm , called EdgeRank , for example, selects the most relevant content for you based on several factors, such as:

  • Posts and pages you like;
  • People you interact with;
  • Pages where you leave comments;
  • Your shares.

Spotify is another example of an app and social network that uses algorithms to offer users a more personalized experience. Every week, the app offers a playlist called “Discoveries of the Week.”

This playlist contains 30 songs that have never been played by the user in the app, but are similar to other songs they usually listen to.

The goal is to introduce users to songs and bands that they don’t know yet, but that are probably compatible with their musical taste.

The algorithms used by social networks can also change. A good example of this is YouTube : initially, the platform prioritized videos with the highest number of views.

However, with the proliferation of clickbaits and web robots ( bots ), tricks used to defraud the counting of views, artificially increasing them, YouTube modified the metric of its algorithm, which began to prioritize the viewing time of videos.

Algorithms in computer programming

Algorithm is a very important concept for programming, as all machines and computer programs work based on sequences of finite actions that lead to the completion of a task.

The programmer’s role is to think about all the stages of the tasks and describe them objectively and clearly so that the computer can perform them.

An example would be a program that shows whether a student passed or failed a certain subject. Considering that the final grade is the average of the two tests taken in the semester, the commands would be:

  1. Collect the grade for both tests taken;
  2. Calculate the arithmetic mean between them;
  3. If the result is greater than 7, the student passed;
  4. If the result is less than 7, the student failed.

However, computers do not understand language written in this way, so programmers must “translate” these commands into programming languages. Some examples of programming languages ​​are:

  • Java
  • C language
  • C++ Language
  • C# Language
  • Python

The operations of an algorithm are performed very quickly by machines. A typical laptop, for example, usually performs more than a billion operations per second.

This operating speed revolutionized the computing world, as machines can perform calculations in a very short time that would take humans days, months or even years to perform.

Applying the algorithm in everyday life

Algorithms arise in mathematics to describe the rules for algebraic equations, but they can be applied to any sequence of finite actions that seek to solve a problem.

All the tasks we perform on a daily basis can be transformed into algorithms, we just need to break down all the actions necessary to achieve the determined objective.

If we were to create an algorithm for preparing coffee, for example, we could have the following steps:

  1. boil water;
  2. put the powder in the filter;
  3. turn off the water;
  4. pass water through the coffee powder.

The algorithms used in computers are more complex and also involve possibilities. Consider the example of a mouse over an internet browser.

The command to close the screen is given by an algorithm that understands that:

  • If the mouse clicks on the “x”, the page should close;
  • If the mouse does not click on the “x”, nothing should be done.

This algorithm can be structured in a flowchart:

Basically, algorithms are composed of input data, processing and output data. This structure can be easily understood with the example of a calculator:

  • Input data : values ​​and operations to be performed
  • Processing : calculations performed by the machine
  • Output data : result of the operation

Leave a Comment

Scroll to Top