# Algorithm

> A precise, step-by-step method for solving a problem or doing a task.

- Level: Basic
- Topics: Software
- URL: https://tidbit.legios.com.ar/algorithm/
- In Spanish: [Algoritmo](https://tidbit.legios.com.ar/es/algorithm/)

An **algorithm** is a finite list of clear steps that, followed exactly, solves a problem. Long division as you learned it at school is an algorithm. So is "to find a word in a paper dictionary, open it in the middle, check whether the word comes before or after, and repeat with that half". Computers need algorithms because they cannot improvise: every program is algorithms written in a programming language.

The same problem can often be solved by several algorithms, and they are not equally good. Checking a dictionary page by page from the start works, but halving it each time (called **binary search**) finds any word in a few dozen steps even in a huge book. Choosing a smarter algorithm usually matters far more than buying a faster computer.

In everyday news the word is used more loosely, as in "the algorithm decided what you see". That usually means a ranking or recommendation system: software that scores posts, videos or ads and puts the highest scores first. Those systems are built from many algorithms, often combined with machine learning models trained on what people clicked before.

## An analogy

A recipe, but one written so precisely that someone who has never cooked, and never thinks for themselves, would still end up with the same cake every time.

## Keep in mind

- A finite sequence of exact steps that solves a problem.
- Different algorithms for the same task can differ enormously in speed.
- Classic examples: sorting a list, searching, finding the shortest route.
- "The algorithm" of a social app is a ranking system built from many of them.

## Go deeper

- [Algorithms course (Khan Academy)](https://www.khanacademy.org/computing/computer-science/algorithms)
- [Algorithm on Wikipedia](https://en.wikipedia.org/wiki/Algorithm)

## Related terms

- [Programming language](https://tidbit.legios.com.ar/programming-language/): A precise, written language people use to give instructions to a computer.
- [Machine learning](https://tidbit.legios.com.ar/machine-learning/): Teaching computers by showing them examples instead of writing every rule.
