# Algorithm in Computer Science

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 computing , an algorithm is a **sequence of sequential instructions , thanks to which certain **processes can be carried out and certain needs or decisions can be responded to. These are ordered and finite sets of steps that allow us to solve a problem or make a decision .

Algorithms have nothing to do with programming languages , since the same algorithm or flowchart **can be represented in various programming languages** , that is, it is an arrangement prior to programming .

Seen this way, a program is nothing more than a complex series of algorithms ordered and coded using a programming language for subsequent 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 *algoritmus* and this surname from the Persian mathematician Al-Juarismi. One of the best-known algorithms in mathematics is the one attributed to Euclid, to obtain the greatest common divisor of two positive integers, or the so-called “Gauss method” to solve systems of linear equations.

## Parts of an algorithm

Every algorithm must consist of the following parts:

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

## What is an algorithm for?

Put very simply, an algorithm **is used to solve a ****problem**** step by step** . It is a series of ordered and sequenced instructions to guide a specific process.

In Computer Science , however, algorithms constitute the skeleton of the processes that will later be coded and programmed to be carried out by the computer.

## Types of algorithms

There are four types of algorithms in computing:

**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 that do not require computer processes to be solved, or whose steps are exclusive for resolution by a human being .**Qualitative algorithms.**It is an algorithm whose resolution does not involve numerical calculations, but rather logical and/or formal sequences.**Quantitative algorithms.**On the contrary, it is an algorithm that depends on mathematical calculations to find its resolution.

## Algorithm characteristics

The algorithms have the following characteristics:

**Sequential.**The algorithms operate in sequence, they must be processed one at a time.**Precise.**Algorithms must be precise in their approach to the topic, that is, they cannot be ambiguous or subjective.**Organized.**Algorithms must be set 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.**Concretes.**Every algorithm must offer a result based on the functions it fulfills.**Defined.**The same algorithm given the same input elements must always give the same results.

## Examples of algorithms

A couple of possible algorithm examples are:

**Algorithm for choosing 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: (return to step 3)

- Is there the right size?

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

- Is the price affordable?

YES: (go to step 7) – NO: (return to step 3)

- Buy the chosen pair of shoes.
- END

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

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