Algorithm

BeginnerMachine Learning

An algorithm is a precise set of step-by-step instructions for solving a problem or completing a task — the fixed procedure a computer follows to turn an input into a result.

What is Algorithm?

Strip away the intimidating word and an algorithm is just a procedure: a clear, ordered list of steps that takes you from a starting point to a finished result. It long predates computers — the method you were taught in school for doing long division by hand is an algorithm, and so is the sequence of steps for assembling a piece of flat-pack furniture. What makes the idea so central to computing is that computers are machines for following procedures exactly, very fast, without getting bored or making slips. Nearly everything a computer does — sorting a list, finding a word on a page, routing a message — is some algorithm being carried out step by step.

In the context of AI, though, the word takes on an extra wrinkle worth understanding. A traditional algorithm is written out in full by a human: the programmer specifies every rule, and the computer follows them precisely. That works beautifully for problems you can spell out completely, but it breaks down for messy tasks like recognizing a face or understanding a sentence, where no one can write down all the rules. This is where machine learning comes in, and it does something subtle: instead of a human writing the step-by-step rules for the task itself, they write an algorithm whose job is to learn those rules from data. So in modern AI there are really two layers — the learning algorithm that does the training, and the trained model it produces, which then makes the predictions. People loosely call both "the algorithm," which is a common source of confusion.

It's also worth noting how the word has drifted in everyday speech. When people complain about "the algorithm" deciding what they see online, they're using it as shorthand for the whole automated system ranking and recommending content — not the narrow technical sense of a single defined procedure. Both usages are valid, but they operate at very different levels: one is a tidy mathematical recipe a student could follow on paper, the other is a sprawling AI system trained on the behavior of millions of people. Keeping that distinction in the back of your mind makes a lot of AI conversation easier to follow.

Real-world example

You're shopping on a website with hundreds of products and you click "sort by price: low to high." In an instant the whole list rearranges itself, cheapest first. Behind that button is a sorting algorithm — a precise, repeatable procedure that compares items two at a time and orders them until the entire list is sorted. It isn't intelligent, it isn't learning anything, and it will produce the exact same correct ordering every single time you run it on the same list. That is an algorithm in its purest, most everyday form: a fixed set of steps that reliably turns one thing (a jumbled list) into another (a sorted one). The clever, learning algorithms of AI are a more sophisticated branch of the very same idea.

Related terms

Frequently asked questions

What is an algorithm in simple terms?

It's a set of step-by-step instructions for getting something done — a precise procedure that takes an input and produces a result. A method for sorting names into alphabetical order is an algorithm; so is the routine your map app uses to find a route. Computers are exceptionally good at following algorithms exactly and quickly, which is why almost everything they do is one algorithm or another being carried out.

What is the difference between an algorithm and artificial intelligence?

An algorithm is the general idea of a step-by-step procedure; AI is a particular, advanced use of algorithms. The key difference is in who writes the rules. In a traditional algorithm, a human writes out every rule and the computer follows them. In AI, especially machine learning, a human writes an algorithm that learns the rules from data rather than being handed them. So AI is built out of algorithms, but not every algorithm is AI — most algorithms are simple, fixed procedures with no learning involved at all.

What do people mean by "the algorithm" on social media?

They're using "the algorithm" loosely to mean the automated system that decides what appears in their feed — which posts to show, in what order, and what to recommend next. Technically that system is made of many algorithms and a machine learning model trained on how people behave, not a single tidy procedure. The everyday phrase has simply come to stand for "the invisible system curating what I see," which is a looser, broader meaning than the strict technical one.