We explain what an algorithm is, the parts it presents and how it is classified. Also, what are its characteristics, advantages and disadvantages.
What is an Algorithm?
An algorithm is called an ordered and structured set of instructions , logical steps or predefined, finite and hierarchical rules, whose successive steps allow carrying out a task or solving a problem, making the relevant decision-making without doubts or ambiguities.
Algorithms are thought schemes widely used in everyday life . Some examples are step-by-step user manuals or software operating guides used in programming and computing as guides.
However, there is no consensus on a formal definition of what it is. This has not prevented its use in mathematics from time immemorial until today.
If an algorithm is not clearly written, it will not give a correct result.
The instructions and steps contained in an algorithm must be precise, that is, they must not leave room for any type of ambiguity .
This is because its instructions must be able to be fully followed and understood , or the flowchart in which it is written will not yield the correct result.
Definition of the algorithm
Every algorithm must be perfectly defined , that is, it must be followed as many times as necessary, always obtaining the same result each time.
Otherwise, the algorithm will not be reliable and will not serve as a guide in decision making.
If an algorithm has no end, a paradox or “loop” will occur.
Algorithms must be finite: they must end at some point or return a result at the end of their steps.
If the algorithm goes on indefinitely, returning to some initial point without ever being able to solve it, we will be in the presence of a paradox or a “ loop ” of repetitions.
The readability of the algorithms is key, because if their content is incomprehensible, the appropriate instructions will not be able to be followed. This implies a direct, clear and concise writing of the text contained in each one.
Parts of an algorithm
Every algorithm has three different parts: input, process, and output.
- Entry. The initial instruction that gives rise to the algorithm and that motivates its reading . It can also be called a start, a header, or a starting point.
- Process. It is about the specific elaboration offered by the algorithm, the body of its keys to formulate an instruction. It can also be called statements.
- Exit. Finally, there are the specific instructions dictated by the algorithm, that is, its resolutions or commands. It can also be called body, foot, or end.
A cooking recipe is a qualitative algorithm.
- According to his system of signs. According to the way they describe the steps to follow, we can talk about:
- Qualitative algorithms. They use text and verbal characters to impart their instructions. For example, a cooking recipe.
- Quantitative algorithms. They use numerical calculations and algebraic operations. For example, a multiplication.
According to their functions. According to the functions of the algorithm, we can talk about:
- Sorting algorithms. They establish a sequence of some kind for the input of some kind of data.
- Search algorithms. As its name implies, it allows you to retrieve a series of specific elements from a specific list.
- Routing algorithms. They determine what process an instruction will follow or how a data set should be transmitted. They can be adaptive (they adapt to the problem) or static (they always operate the same).
According to your strategy. According to the method used to produce its results, we can be in the presence of:
- Probabilistic algorithms. They offer a margin of probability as a result, so there is no total certainty of their accuracy.
- Heuristic algorithms. They are used when traditional methods fail to deliver a solution since they abandon some objective to achieve a possible result.
- Everyday algorithms. Those used in day-to-day decision-making and that belong to the field of the simplest.
- Climbing algorithms. They modify the process as the solution is unsatisfactory (it does not comply with the input and output) until it approaches what is sought.
- Deterministic algorithms. They operate in a linear fashion, so that their results can be predicted and can be applied to controlled processes.
Advantages and disadvantages of an algorithm
Algorithms usually require prior and above all technical knowledge.
Working with algorithms has the following strengths and weaknesses:
- Advantages. They allow the sequential ordering of the processes and therefore reduce the possible range of errors, helping to solve the problems raised faster and easier. In addition, they are accurate and allow you to stick to a specific guide.
- Disadvantages. They usually require prior and above all technical knowledge , since algorithms are often expressed (except for the most common and simple ones) in a language adapted to the case in question. On the other hand, blind reliance on a logical method of solving problems can obviate more innovative but unpredictable creative solutions.
Steps to formulate an algorithm
To propose a suitable algorithm, it is necessary to follow these three steps:
- State the problem. This is key, since the way in which we pose the problem will be the specific approach that will help us to reach a solution. You must collect data, approach the problem from a broad perspective and at the same time timely.
- Analyze the general solution. Previous data should be cross-referenced with possible solutions and exploration of possible work areas, formulas, and other tools. Then, approach various attempts at a solution.
- Elaborate the algorithm. Once the path to follow has been chosen, the appropriate type of algorithm must be chosen and proposed, and then put to the test and determine if it is exactly the desired solution.
Representation of an algorithm
The digital programming language is a type of algorithm.
Algorithms are usually represented by natural language (verbal) , codes of all kinds, flow charts, programming languages or simply mathematical operations. A visual diagram is also usually applied.
Two algorithm examples can be:
- Mathematical. To determine the average of four school grades: 10, 9, 8, 7.
- Sum of the notes 10 + 9 + 8 + 7 = 34
- Division by the number of notes 34/4 = 8.5
- Result 8.5
- Verbal. To make a melon smoothie.
- Peel the melon and chop it into cubes.
- Insert the cubes in a blender.
- Plugging in the blender if it is not plugged in
- Turn on the blender and blend for 2 minutes
- Turn off the blender and unplug it
- Strain the juice and serve it in a jug
The above content published at Collaborative Research Group is for informational and educational purposes only and has been developed by referring reliable sources and recommendations from technology experts. We do not have any contact with official entities nor do we intend to replace the information that they emit.