Sometimes we hear that word in movies or from a programmer or systems engineer, and we’re not entirely sure how it comes about or how it’s defined. The truth is that all of us, without exception, are capable of designing and executing algorithms.
Let us remember that algorithms do not refer only to programming, for a whole day, we carry out algorithms without realizing it or without knowing that they have that name, by definition, we know algorithms as an ordered sequence of steps that solve a problem, That is why common situations, such as going to work, exercising or watching a movie, are all actions that are carried out following algorithms.
To show visually, suppose we want to go to the supermarket. To do this, we must follow the steps indicated below.
Step 1. Select Supermarket
Step 2. Select means of transport
Step 3. Go to the supermarket
Step 4. Make purchases
As we can see, with a series of steps we achieve a situation, these steps are not carved in stone, we can modify or add new steps, it all depends on the approach we are giving it.
Just like this example, there are many in our day to day, however, in programming, it is important to always keep in mind that these steps are designed to solve a specific problem. Perhaps we do not consider going to a supermarket a problem, but if we approach it from a technological point of view, we could say that we want to go to the supermarket, in a time of 1 hour, already with this change of approach, our algorithm changes and adapts to what is required.
With current technologies, we can calculate the distance between point A (My current location) and point B (Supermarket), to calculate the approximate time it may take to come and go and, based on that value, know if we are going to be able to comply with the request to make purchases in an hour.
That is why we have listed 10 important points to consider about algorithms.
1.- Flexibility at all times. The algorithms are capable of adapting to each situation, despite already having a defined step-by-step, that does not mean that new steps cannot be eliminated or added, all to be able to solve a problem or optimize the solution.
2.- Think of simple solutions. Sometimes we can be faced with a fairly complex problem, which is why it is recommended to divide the problem into small problems with their solution. This allows faults or improvements to be detected early in development.
3.- Fewer steps, More efficiency. In cases where it is possible, it is advisable to have only a few steps to solve a problem, this translates into less code, which offers a more efficient development.
4.- Determine several solutions. When we are faced with a problem, all possible solutions must always be seen, it is very similar to when we want to go to a specific point and we are given transportation solutions such as going by plane, car, or rail. All these are valid solutions, they meet our requirement, however, there are differences between them, such as, for example, the time it takes to move. The most optimal option should always be selected.
5.- Test before executing. Either with the pseudocode or through a flowchart, the steps that are being followed must be tested and guarantee that the problem is being solved. Similarly, if we are dealing with an already designed algorithm, as we discussed in the previous point, see several possible solutions and determine which is the most optimal solution.
6.- Analyze the order well. At this point, you must be analytical, be able to see the order in which the steps are being done most efficiently. We can find that sometimes the repetitive structures are loading the process of a useless time to give data that can be obtained more directly. It is similar to our walk, first we move the right leg and then the left leg, if we jump on one leg, we reach our destination, but tired and with a great loss of time.
7.- Identify correctly. Data is the main basis for an algorithm to work, which is why identifying what information is required is crucial, sometimes we can request a series of data that we can suddenly obtain through a repetitive structure.