# Computer Algorithm

We explain what a computer algorithm is and what it is for. Characteristics and parts of an algorithm. Practical examples.

### What is an algorithm?

In computer science, an algorithm is a **sequence of sequential instructions**, thanks to which certain processes can be carried out and respond to certain needs or decisions. These are ordered and finite sets of steps, which allow us to solve a problem or make a decision.

The algorithms do not have to do with programming languages, since the same algorithm or flowchart **can be represented in different programming languages**, that is, it is an ordering prior to programming. .

Seen this way, a program is nothing more than a complex series of algorithms ordered and coded by a programming language for later execution on a computer.

Algorithms are also frequent in mathematics and logic, and are **the basis for the manufacture of user manuals, instruction booklets, etc.** Its name comes from the Latin *algorithmus* and this last name of the Persian mathematician Al-Juarismi. One of the best known algorithms of mathematics is that attributed to Euclid, to obtain the maximum common divisor of two positive integers, or the so-called Gauss method. to solve systems of linear equations.

See also: Flowchart.

### Parts of an algorithm

Every algorithm must consist of the following parts:

**Input or input**. The input of the data that the algorithm needs to operate.**Process**. This is the formal logical operation that the algorithm will undertake with the input received.**Output or output**. The results obtained from the process on the input, once the execution of the algorithm is finished.

### What is an algorithm for?

Simply put, an algorithm **serves to** **solve a problem step by step** . It is a series of ordered and sequenced instructions to guide a particular process.

In Computer Science, however, algorithms constitute the skeleton of the processes that will then be encoded and programmed to be performed by the computer.

### Types of algorithms

There are four types of computer algorithms:

**Computational algorithms**An algorithm whose resolution depends on the calculation, and which can be developed by a calculator or computer without difficulties.**Non-computational algorithms**Those who do not require the processes of a computer to resolve, or whose steps are exclusive to the resolution by a human being.**Qualitative algorithms**It is an algorithm whose resolution does not involve numerical calculations, but logical and / or formal sequences.**Quantitative Algorithms**On the contrary, it is an algorithm that depends on mathematical calculations to find its resolution.

### Characteristics of the algorithms

The algorithms have the following characteristics:

**Sequential**The algorithms operate in sequence, must be processed one at a time.**Accurate**. The algorithms must be precise in their approach to the subject, that is, they cannot be ambiguous or subjective.**Ordered**The algorithms must be established in the precise and exact sequence so that their reading makes sense and the problem is solved.**Finite**Every sequence of algorithms must have a specific purpose, it cannot be extended to infinity.**Concrete**. Every algorithm must offer a result based on the functions it fulfills.**Defined**The same algorithm before the same input elements must always give the same results.

### Algorithm Examples

A couple of possible examples of algorithm are:

**Algorithm to choose some party shoes** :

- START
- Enter the store and look for the men's shoes section.
- Take a pair of shoes.
- Are they party shoes?

YES: (go to step 5) - NO: (go back to step 3)

- Are there the right size?

YES: (go to step 6) - NO: (return to step 3)

- Is the price payable?

SI: (go to step 7) - NO: (return to step 3)

- Buy the chosen pair of shoes.
- FINISH

**Algorithm to calculate the area of a right triangle** :

- START
- Find the measurements of the base (b) and height (h)
- Multiply: base by height (bxh)
- Divide the result by 2 (bxh) / 2
- FINISH