What is an algorithm?
In one line
Ages 8 to 10: An algorithm is a set of clear steps, like a recipe, that anyone can follow to get the same job done.
Ages 11 to 13: An algorithm is a precise, finite list of steps that turns an input into an output, and some algorithms need far fewer steps than others.
Ages 14 to 18: An algorithm is a finite, unambiguous procedure from input to output, judged by whether it is correct and how its work grows with the size of the input.
An algorithm is a list of clear steps that solves a problem or gets a task done. Each step says exactly what to do, and the steps always come to an end. Computers follow algorithms to search, sort, calculate and decide, and people follow them too.
Last reviewed: 20 October 2026 7 min read
The idea in one picture
A recipe is an algorithm for a cake: exact steps, in order, with a clear finish. The steps are so clear that someone who has never baked can follow them and get the same result.
Worked example: guess my number from 1 to 100. Two algorithms for the same job:
- Algorithm A (one by one): guess 1, then 2, then 3, and so on. If the number is 100, that takes 100 guesses.
- Algorithm B (halve it): always guess the middle of the numbers that are still possible. The answer "higher" or "lower" throws away half of them each time.
Say the secret number is 37. Algorithm B goes:
| Guess | Still possible before the guess | Answer |
|---|---|---|
| 50 | 1 to 100 | lower |
| 25 | 1 to 49 | higher |
| 37 | 26 to 49 | correct |
Algorithm B never needs more than 7 guesses for any number from 1 to 100, because halving 100 seven times leaves less than one number. Both are algorithms. One is far faster.
How it works, step by step
- Start with an input. The input is what the algorithm works on: a number to find, a list to sort, a map to cross.
- Follow exact steps. Each step is precise, so two people, or two computers, following it do the same thing.
- Make decisions. Many steps are checks: "if the answer is higher, keep the top half".
- Repeat where needed. A loop repeats a step until a condition is met, such as "until the number is found".
- Stop with an output. An algorithm always finishes after a limited number of steps and gives a result.
A little deeper (ages 11 to 13)
Computer scientists check two things about an algorithm: is it correct, and how much work does it take?
Correct means it gives the right output for every allowed input, not just the ones you tried. The halving algorithm only works if the numbers are in order. Run it on a shuffled list and it can miss the target completely.
Work is counted in steps. For 1 to 100, one-by-one guessing needs up to 100 guesses and halving needs up to 7. For 1 to 1,000, one-by-one needs up to 1,000, while halving needs only up to 10, because 2 × 2 × … ten times is 1,024. When the input grows ten times bigger, the halving algorithm needs only about 3 more guesses.
Going further (ages 14 to 18)
A classic description lists five properties: an algorithm is finite (it always ends), definite (every step is unambiguous), has zero or more inputs, has one or more outputs, and is effective (every step is basic enough to do exactly, in principle, with pencil and paper).
Efficiency is described by how the number of steps grows with the input size n. One-by-one search grows in proportion to n. Halving, called binary search, grows with log₂ n, the number of times n can be halved before reaching 1. For a million sorted items that is about 20 comparisons instead of up to a million.
In machine learning, two different things are often both called "the algorithm". A training algorithm, such as gradient descent, is the step-by-step procedure that adjusts a model's numbers to fit the examples. The model is what comes out: the learned numbers and structure that turn a new input into a prediction.
When people say "the algorithm" about a social media feed, they usually mean a recommendation system: algorithms and models that rank what to show next, toward goals people set.
Common mix-ups
- Mix-up: "Algorithms are only for computers."Fact: A recipe and long division are algorithms too. Computers just follow them fast.
- Mix-up: "An algorithm and a program are the same thing."Fact: The algorithm is the method. A program is that method written in a particular programming language.
- Mix-up: "Algorithms are always fair and neutral."Fact: An algorithm does exactly what its steps say. If people choose unfair steps, or a model learns from unfair examples, the results can be unfair.
- Mix-up: "If it worked on my test, it works."Fact: Correct means correct for every allowed input. The halving algorithm fails on an unsorted list even if it got lucky once.
Try it (no device, 5 minutes)
Write an algorithm for making a jam sandwich, in no more than eight steps. A second person follows it exactly as written and nothing more: if a step says "put jam on the bread" without "open the jar", the jar stays shut. Rewrite until it works. Then play guess my number from 1 to 100 using halving, and count the guesses. It is never more than 7.
Quick check
Is "bake until it looks nice" a clear algorithm step?
Answer: Not really. "Looks nice" means different things to different people. "Bake for 25 minutes at 350 °F" is exact, so anyone gets the same result.
Not really. "Looks nice" means different things to different people. "Bake for 25 minutes at 350 °F" is exact, so anyone gets the same result.Using halving on 1 to 100, the secret number is 80. What is your first guess, and what is the answer?
Answer: Guess 50. The answer is "higher", so 1 to 50 are thrown away and 51 to 100 are left.
Guess 50. The answer is "higher", so 1 to 50 are thrown away and 51 to 100 are left.Why does the halving algorithm need a sorted list?
Answer: "Higher" or "lower" only tells you which half to throw away if the numbers are in order. On a shuffled list, the target could be in the half you threw away.
"Higher" or "lower" only tells you which half to throw away if the numbers are in order. On a shuffled list, the target could be in the half you threw away.Questions
An algorithm is a set of clear steps for doing a job, like a recipe. Each step says exactly what to do, and following the steps always leads to an end and a result.
A recipe, the method for long division and the directions to someone's house are all algorithms. Each one is a fixed list of steps that anyone can follow and get the same result.
No. An algorithm is the method, and a program is that method written in a programming language so a computer can run it. One algorithm can be written as many different programs.
They usually mean the recommendation system that chooses what to show next. It is made of many algorithms and models that rank posts or videos using signals such as what people watched before, toward goals that people at the company set.
Machine learning uses algorithms. A training algorithm adjusts a model's numbers to fit examples, and the trained model is then used to make predictions about new cases. ---
Mechna Academy is a city of machines for curious children aged 8 to 18, opening first to ages 8 to 10. In each mission, a child guesses how a machine decides, then opens its Peek Hatch to check, changes one thing and tests it on a case it has never seen. Children learn how AI works this way, and they never chat with an AI.
For grown-ups: join the waitlistPlaces are limited. The waitlist is for parents and guardians 18 and older.