Black October, explainedAppsGuidesAI DictionarySmall FixesOn RecordAboutFollow the lab

Algorithm

Also called algo

An algorithm is a precise, step-by-step recipe for solving a problem, written clearly enough that a computer can follow it without guessing.

The basicsEveryday

In plain words

A recipe says: boil water, add tea, add milk, wait until it rises, strain. Follow it and you get chai. That is an algorithm: a fixed list of steps that turns a starting point into a result.

Computers only do what they are told, so their recipes must be exact. Every step clear, every choice spelled out (if the milk has risen, stop; if not, keep waiting), and a clear end.

All software is built from algorithms: sorting your contacts, finding the fastest route, checking a UPI PIN.

In AI the word is used in two ways. There is the learning algorithm, the recipe that trains a model from data. And there is what people call "the algorithm" on social media: a system that ranks posts, which today usually includes machine learning models.

Everyday example

Making chai at home

Put water on the stove. Add tea leaves and ginger. When it boils, add milk and sugar. Watch the pot: has it risen? If not, keep watching. If yes, turn off the flame and strain into cups. Every home cook follows a loop and a decision like this without thinking. Write it so precisely that a robot could follow it, and you have an algorithm.

Where the example breaks: A cook adjusts by taste and improvises when the ginger runs out. An algorithm does exactly what it says and nothing more, so a missing step or a case nobody planned for makes it fail or behave oddly.

Go deeper

How it actually works

Britannica defines an algorithm as a systematic procedure that produces the answer to a question in a finite number of steps.

  1. Input, steps, output

    Every algorithm takes some input, applies well-defined steps and produces output. Steps can be simple actions, decisions (if this, then that) and loops (repeat until something is true).

  2. Correct and efficient

    A good algorithm gives the right answer for every valid input without wasting time or memory. Two algorithms can solve the same problem at very different speeds: sorting a million names can take a moment or hours depending on the method.

  3. Learning algorithms

    In machine learning, people write the learning algorithm, such as gradient descent. It reads training data and produces a model. The model's inner rules were found by the algorithm, not typed by a person.

  4. Ranking algorithms

    Feeds, search results and shopping suggestions are ordered by ranking systems that mix hand-written rules with learned models, tuned for goals such as clicks or watch time. They can carry bias from the data they learn from.

Word origin
From al-Khwarizmi, a 9th-century mathematician
The Indian link
The Latin title of his arithmetic book was "Algoritmi de numero Indorum". It taught the Hindu way of reckoning with numerals
Classic examples
Sorting, searching, shortest route, encryption
In AI
Learning algorithms build models; models make predictions

Questions people ask

What is the difference between an algorithm and AI?

An algorithm is any precise set of steps. AI is the goal of computers doing tasks that seem to need intelligence. AI systems use algorithms, but most algorithms, like a calculator adding numbers, are not AI. A machine learning algorithm is one that learns its rules from data.

What is the difference between an algorithm and a model?

In machine learning, the algorithm is the recipe for learning. The model is what that recipe produces: a set of learned numbers that can make predictions. Same algorithm, different data, different model.

What does "the algorithm" mean on social media?

It is shorthand for the ranking system that decides which posts you see and in what order. It weighs signals such as what you watched, liked and skipped, and usually includes machine learning models trained to predict what will keep people engaged.

Where does the word algorithm come from?

From the name of al-Khwarizmi, a 9th-century mathematician. A Latin translation of his arithmetic book was titled "Algoritmi de numero Indorum", and the book taught the Hindu way of reckoning with the numerals much of the world uses today.

Further reading