Algorithm in Computer Science
- What is an algorithm?
- Parts of an algorithm
- What is an algorithm for?
- Types of algorithms
- Characteristics of the algorithms
- Algorithm Examples
We explain what a computer algorithm is and what it is for. Characteristics and parts of an algorithm. Practical examples.
Basically an algorithm is used to solve a problem step by step.
What is an algorithm?
In computing, an algorithm is a sequence of sequential instructions, thanks to which certain tasks can be carried out. processes and respond to certain needs or decisions. These are ordered and finite sets of steps, which allow us to solve a problem. issue either make a decision.
Algorithms have nothing to do with programming languages, given that the same algorithm or Flowchart can be represented in various programming languages, that is, it is an ordering prior to the programming.
Seen this way, a program is nothing more than a complex series of algorithms ordered and coded using a programming language for later execution in a computer.
Algorithms are also prevalent in mathematics and the logic, and are the basis for the manufacture of user manuals, brochures of instructions, etc Its name comes from the Latin algorithms and this surname of 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. The income of 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. issue. It is a series of ordered and sequenced instructions to guide a certain process.
in the sciences of computingHowever, the algorithms constitute the skeleton of the processes that will later be codified and programmed to be carried out by the computer.
Types of algorithms
There are four types of algorithms in computer science:
- Computational algorithms. An algorithm whose resolution depends on computation, and which can be performed by a calculator or computer without difficulty.
- Non-computational algorithms. Those that do not require the processes of a computer to solve, or whose steps are exclusive for the resolution by a computer. 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
An algorithm must offer a result based on its functions.
The algorithms have the following characteristics:
- Sequential. The algorithms operate in sequence, they must be processed one at a time.
- Accurate. Algorithms must be precise in their approach to the subject, 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 solves the problem.
- Finites. 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.
A couple of possible algorithm examples are:
Algorithm for choosing party shoes:
- Enter the store and look for the section of men's shoes.
- Take a pair of shoes.
- Are they party shoes?
YES: (go to step 5) – NO: (go back to step 3)
- Is there the right size?
YES: (go to step 6) – NO: (go back to step 3)
- Is the price payable?
YES: (go to step 7) – NO: (go back to step 3)
- Buy the chosen pair of shoes.
Algorithm to calculate the area of a right triangle:
- Find the measurements of the base (b) and height (h)
- Multiply: base times height (b x h)
- Divide by 2 the result (b x h) / 2