What is an algorithm?

Learning data structures and algorithms is crucial to be a great developer. It is always mentioned in valuable tutorials, to have a…

What is an algorithm?

Learning data structures and algorithms is crucial to be a great developer. It is always mentioned in valuable tutorials, to have a concrete knowledge about basic algorithms.

Algorithm is a specific procedure to solve computational problems.

Algorithms are used to perform calculations and data processing. Well defined algorithms are extremely useful in different kind of apps.

How to define in easy words what exactly algorithm is?


Algorithm in easy words

While coding, a programmer is trying to give instructions to a computer, which tasks execute and how to do it.

It is not a big mystery that firstly, the code is compiled, then translated to language that computer understands.

After receiving these informations, computer starts proceeding attached tasks. That is the moment when algorithm is needed.

Algorithm defines the provided instruction, including steps which computer is executing one by one.

Example:

Let’s say that we need to go out to our friends for a party. We can overcome a road in different ways, every method can be a separate algorithm:

The Uber algorithm:

  • Open an app and type the destination,
  • Accept the driver,
  • Overcome the road,
  • Execute the payment through an app.

The public transport algorithm:

  • Make a research about the concrete lines which can drive you,
  • Buy a ticket,
  • Take the bus,
  • Overcome the road.

The own car algorithm:

  • Take the car and drive to the target.

Each algorithm solve the problem, but in very different ways, costs and performance. The same situation is with computers.

Performing tasks can be executed differently with the same result, but for example with another memory consumption. This parameter can slow an application and in the end, it will be not sufficient for commercial use case.

Taking care of finding efficient procedure is crucial while constructing a great algorithm.

Sorting

Sorting is the subject in computer science, which required a lot of researches about a performance and spend time on executing the function.

Programmers from all around the world created many kinds of sorting algorithms and each of these has different properties.

The basic sorting algorithms:

  • Bin sort,
  • Merge sort,
  • Bubble sort,
  • Shell sort,
  • Quicksort

Each of mentioned above algorithms has different sorting time, memory consumption, etc. It is conditioned, by what we want to sort.

For example, if you have thousands, millions of integer values between 1 and 10, the bin sort algorithm will perform the most effective.

However, if you have million string values as a title of a movie, the quicksort algorithm is the best choice.

Below I share with you a link to animated sorting simulations, getting acquainted with that can be very helpful in understanding the definition of an algorithm.

https://visualgo.net/en/sorting


The net worth of the best algorithms

The worth of an excellent algorithm can be extremely high. It can be like a receipt for Coca Cola or KFC chickens. It describes how valuable it is in apps.

Google searching algorithm is worth over 180 billions of dollars. Akamai’s algorithm for web content delivering is worth over 6 billions of dollars. Cisco algorithms are worth over 159 billions usd. These numbers are ridiculous, there are even tasks for finding a proper algorithm and it is totally paid by investors in millions of dollars.

Why to learn algorithms? Hope you know the answer.


The beginner tip

As a newbie I started my journey with coding, by implementing some sorting algorithms in C++, it gave me a lot of confidence in continuation of the development process.

It is highly recommended to try implementing these algorithms in the programming language you learn, so that the good habits of seeking great and efficient solutions can be quickly adapted.