What is an algorithm?

The very first time I heard the word algorithm, the first thing that came to my mind was a very complex process that involves mathematical formulas, a process that would be very difficult to understand. I tried to find an easy definition so that it could get stuck in my mind since I will be using algorithms all the time throughout my career as a Data Scientist. After much research, I came up with a simple definition: an algorithm is a list of steps that you need to solve a problem or to get something done. An easy way to understand what is an algorithm is to compare it with a meal recipe. When we cook a meal, the first thing we need is a list of ingredients, secondly we need to follow the steps in a specific order and finally if we don’t make any mistakes during the process, we are going to get the desired meal. In computer science lingo our list of ingredients are the inputs, our recipe is the procedure and our desired meal is the output. A programming algorithm is a procedure that describes the steps needed for a computer to solve a problem. The instructions that I give to the computer have to be simple and very clear, they can not be ambiguous. It’s also important to explain the steps in the right order so that you can get the correct results you are looking for.

An important property for a good algorithm is that it has to be efficient with time and memory space. We can define time efficiency by the amount of time that an algorithm used to be executed and space efficiency by the amount of memory needed for an algorithm to solve a problem.

Depending on the problem that we want to solve, we have to choose the right algorithm. For example, if we want to sort a list of numberswe can use merge sort, bubble sort, quick sort, shell sort or bin sort. There are many flavors of a family of algorithms called divide and conquer. All of these algorithms share the same approach, divide our list into small sublists and then order the elements. Depending on the amount of elements that we are going to sort, we have to choose between one or another algorithm. Bin sort can be used if our list of numbers are small, however if we want to order millions of numbers, quick-sort is the right choice.

In summary, algorithms are a key component of Data Science so as students the earlier we start familiarizing and learning about them the better it will be down the line.

Previous
Previous

Why Graph Databases Are The Future