Algorithm
An algorithm is a precise, step-by-step procedure for getting a result. In AI, learning algorithms are the procedures that turn data into a trained model.
An algorithm is a precise list of steps for getting a result. Scanning a list one item at a time to find its largest number is an algorithm. So is a recipe followed to the letter. The steps must be exact enough that a computer, which has no common sense, can carry them out without guessing.
The largest-number procedure is deterministic: hand it the same list twice and it does the same work and returns the same answer. Speed matters as well: computer scientists track how long an algorithm needs to reach its result. Algorithms can also carry built-in assumptions. K-means, a common way to sort data into groups, must be told how many groups to find and copes poorly with oddly shaped ones.
Machine learning adds a second kind. A learning algorithm, such as gradient descent, does not answer the question directly. It describes how to adjust a model’s internal numbers, a little at a time, until the model’s guesses on known examples are as good as they can get. The output is a trained model, and it is the model that then answers new questions. So the learning algorithm and the model it produces are two separate things: one builds, the other predicts.
Computers need every step spelled out.
Two kinds of algorithm, side by side.
- 1 · goalStart from a clear result you want, such as the largest number in a list or the lowest possible error.
- 2 · stepsWrite a sequence of precise steps that a computer can carry out exactly.
- 3 · codeImplement the steps in a programming language; the program is one realisation of the algorithm.
- 4 · learnIn machine learning, the steps describe how to adjust a model's numbers using examples, repeated many times.
- 5 · resultA classic algorithm returns an answer. A learning algorithm returns a trained model that produces answers later.
In machine learning, the algorithm and the model are two different things: the learning algorithm builds the model, and the model does the predicting.
| Who | What they ask | What it works with |
|---|---|---|
| Programmer | “What is the largest value in this list?” | A classic procedure that compares one item at a time |
| Streaming service | “Which show should this viewer see next?” | A recommender system that adapts to their preferences |
| ML engineer | “How should the model's weights change to cut its error?” | Gradient descent, run over the training data |
| Data analyst | “Which customers behave alike?” | A clustering algorithm such as k-means |
- Turns a task into steps a computer can follow without guessing.
- A deterministic algorithm gives the same result for the same input, so its behaviour can be predicted.
- Learning algorithms can pull a pattern, such as how weather relates to rain, out of large amounts of data.
- Getting the right answer is not enough on its own: how long an algorithm needs to reach its result matters too.
- A learning algorithm cannot fix unrepresentative data: if the examples describe a different group from the one the model will serve, its answers can be wrong.
- Many algorithms need settings picked by people, such as how many groups k-means should look for.
Sources used
This explainer is written in original language. The links below support its factual claims.
- officialalgorithm (Dictionary of Algorithms and Data Structures), NIST · read 27 Sept 2026
- docsIntroduction to Computer Science, 3.1 Introduction to Data Structures and Algorithms, OpenStax (Rice University) · read 27 Sept 2026
- docsMachine Learning Glossary, Google for Developers · read 27 Sept 2026
- docsLinear regression: Gradient descent (Machine Learning Crash Course), Google for Developers · read 27 Sept 2026
- officialUpdates to the OECD's definition of an AI system explained, OECD.AI · read 27 Sept 2026
- docs2.3. Clustering (User Guide), scikit-learn · read 27 Sept 2026
- officialdeterministic algorithm (Dictionary of Algorithms and Data Structures), NIST · read 27 Sept 2026
- docsWhat is Machine Learning? (Introduction to Machine Learning), Google for Developers · read 27 Sept 2026