In short

An algorithm is an unambiguous sequence of steps that solves a problem in a finite number of steps. People use algorithms when cooking from a recipe, computers when sorting, searching and planning routes. What matters are unambiguity, finiteness and efficiency. A program is merely the implementation of an algorithm in a programming language.

  • Definition: An algorithm is a precise instruction that leads step by step to a result.

  • Properties: Every step is unambiguous, the description is finite and the process ends with a result.

  • Everyday life: Satnav, search engine, spam filter and social media feed work with algorithms.

  • Efficiency: Binary search finds one entry among a million in at most 20 steps.

  • Program: Code is the translation of an algorithm for a machine.

What is an algorithm?

An algorithm is an unambiguous instruction that solves a problem in a finite number of steps. Germany's Federal Agency for Civic Education describes it as a precisely formulated set of instructions for a machine or a person. An algorithm therefore does not need a computer.

Computer science defines the term more concisely. The NIST Dictionary of Algorithms and Data Structures calls an algorithm a computable set of steps to achieve a desired result. The name goes back to the Persian scholar al-Khwarizmi, who wrote a book on arithmetic in the 9th century.

A recipe is the classic example. It lists the ingredients (input), the work steps (processing) and the finished dish (output). If a step is missing or unclear, the dish fails (cooks know this from "a pinch of salt").

What properties does an algorithm have?

An algorithm meets several formal conditions. Only then can a computer execute it without asking questions. Textbooks phrase the list slightly differently, but at its core they agree.

Property

Meaning

Example

Unambiguity

Each step allows only one interpretation.

"Boil water for 10 minutes" instead of "boil water for a while"

Finiteness

The description consists of a finite number of steps.

A recipe fits on one page.

Executability

Each step can actually be carried out.

"Divide by zero" cannot be executed.

Termination

The process ends after a finite number of steps.

The search stops when the entry is found.

Determinism

The same input leads to the same result.

A calculator always returns 56 for 7 × 8.

Not every algorithm is deterministic. Randomised methods deliberately produce different results for the same input. They are used in simulations, for example.

Where do you encounter algorithms?

Algorithms are in almost every digital device you use every day. Some examples:

  • The satnav calculates the shortest route, for example with Dijkstra's algorithm.

  • The search engine sorts results by relevance.

  • The spam filter checks incoming emails against features and rules.

  • Online banking protects passwords with hash functions.

  • Streaming services and social networks recommend content based on your behaviour.

  • The supermarket checkout adds up prices and calculates the change.

You follow algorithms even without technology. Assembly instructions for a shelf or the sequence for crossing a road are step sequences with a clear goal.

How does an algorithm work in practice?

An algorithm takes an input, processes it in fixed steps and outputs a result. The Euclidean algorithm illustrates this well. It determines the greatest common divisor (GCD) of two numbers and goes back to the Greek mathematician Euclid.

The rule is: divide the larger number by the smaller one and note the remainder. Repeat this with the smaller number and the remainder until the remainder is zero. The last divisor is the GCD.

Step

Calculation

Remainder

1

48 divided by 18

12

2

18 divided by 12

6

3

12 divided by 6

0

The GCD of 48 and 18 is 6. The procedure works for all positive integers and always ends. That is exactly what makes it an algorithm.

How do algorithm and program differ?

The algorithm describes the solution; the program implements it in a programming language. The same algorithm can be written in Python, Java or C. The solution remains the same, only the notation changes.

Before programming, developers often describe algorithms as pseudocode or a flowchart. The source code is created from this. A compiler translates this code into machine language, which the processor executes as binary code. An error in the algorithm remains an error even in the best code.

What does efficiency mean for algorithms?

Efficiency describes how many steps or how much memory an algorithm needs for a task. Two algorithms can deliver the same result and still differ greatly in speed.

One example is searching a sorted list. Linear search checks each entry one after the other. Binary search halves the search range at every step.

Entries in the list

Linear search (worst case)

Binary search (worst case)

1,000

1,000 steps

10 steps

1,000,000

1,000,000 steps

20 steps

Computer science describes such differences with big O notation. Linear search has complexity O(n), binary search O(log n). With large amounts of data, the choice of algorithm decides between seconds and hours.

When do algorithms become critical?

Algorithms become critical when they influence decisions about people. This applies to credit scoring, applicant selection or the ranking of news in social networks, for example. Many of these systems use machine learning and learn their rules from data.

Two problems follow from this. Errors or biases in the training data carry over into the results. In addition, it is difficult to understand why the system decides the way it does. The EU responds with transparency obligations. Article 27 of the Digital Services Act requires online platforms to disclose the main parameters of their recommender systems.

Frequently asked questions

What is an algorithm in simple terms?

An algorithm is an exact set of instructions that leads step by step to a result. A recipe or assembly instructions are simple examples.

Is every computer program an algorithm?

A program implements one or more algorithms. However, many programs run continuously, such as an operating system, and do not end after one task. Strictly speaking, the program is the implementation and the algorithm the procedure behind it.

Where does the word algorithm come from?

The word goes back to the name of the Persian scholar al-Khwarizmi. In the 9th century he described arithmetic procedures that became known in Europe through Latin translations.

Is artificial intelligence an algorithm?

AI systems consist of algorithms, for example for training neural networks. The difference is that the rules of the finished model are learned from data rather than written by hand.

What is an efficient algorithm?

An efficient algorithm solves a task with few steps and little memory. Binary search is an example: it needs at most 20 comparisons for a million sorted entries.

By

Sabine Clarke

Editor, Tech Fundamentals

Sabine Clarke writes short, precise explanations of technical terms and basics at Tech Brevier: from APIs and cloud models to encryption, AI and data formats.

Each article first answers the question in one or two sentences, then goes deeper with examples. She relies on standards, official documentation and recognised reference works.