Algorithm
⚡ An algorithm is a step-by-step set of instructions that tells a computer how to solve a problem — like a recipe for a machine. There are three kinds in AI: programming algorithms (a human writes every step), ML algorithms (the machine learns the steps from data), and deep learning algorithms (the machine learns using […]
⚡ An algorithm is a step-by-step set of instructions that tells a computer how to solve a problem — like a recipe for a machine. There are three kinds in AI: programming algorithms (a human writes every step), ML algorithms (the machine learns the steps from data), and deep learning algorithms (the machine learns using many layers, like peeling an onion).
Category: Foundational Concepts · Difficulty: Beginner · Last updated: 15 May 2026 · 5 min read
What is an algorithm?
Imagine you are three years old and you want a peanut butter sandwich. Your parent tells you:
- Get two slices of bread.
- Open the peanut butter jar.
- Use the knife to spread peanut butter on one slice.
- Put the other slice on top.
- Done.
That list of steps is an algorithm.
It has a clear start. It has clear steps in order. It ends with a result. That is all an algorithm ever is — a recipe for getting from a problem to an answer.
Computers cannot guess. They cannot think creatively. They cannot figure things out on their own — unless they are given an algorithm that tells them exactly how. Every single thing a computer does, from loading a webpage to generating an image, is the result of one or more algorithms running in sequence.
The word sounds complicated. The idea is not.
Programming, ML Algorithms, Deep Learning Algorithms
Not all algorithms work the same way. In the world of AI, there are three distinct types. They all follow instructions — but who writes those instructions is very different.
Programming algorithms — a human writes every step
A programming algorithm is written entirely by a human. The programmer thinks through every possible situation, writes a rule for each one, and the computer follows it exactly.
Example: A calculator. When you press 4 + 3, the algorithm says: take the first number, add the second number, show the result. Every step was written by a human. The computer never had to think — it just followed the recipe.
Another example: Traffic lights. A programmer writes: “If it has been 30 seconds on green, switch to yellow. If it has been 5 seconds on yellow, switch to red.” Simple, fixed rules written by a human.
The limit: programming algorithms break the moment a situation arises that the human did not write a rule for. You cannot write a rule for every possible human face. You cannot write a rule for every possible sentence in every language. This is where ML and DL take over.
Machine Learning algorithms
A machine learning algorithm does not have its steps written by a human. Instead, it is given thousands or millions of examples and it finds the patterns itself.
Example: Spam detection. You do not write rules like “if email contains the word ‘winner’ it is spam.” That would break instantly. Instead you show the ML algorithm 10 million emails labelled “spam” or “not spam.” It studies them, finds what makes spam emails different from real ones, and builds its own invisible set of rules. Now it catches spam you never thought of.
Example: Recommending a Netflix show. Netflix does not have a human writing “if someone watches crime shows, suggest these 5 titles.” An ML algorithm watches what millions of people watch, finds patterns in their behaviour, and builds personalised suggestions for each person automatically.
The machine did not get instructions. It read the data. It figured it out.
The limit: ML algorithms need you to point them at the right features. A human still has to look at the data and decide what to feed the algorithm. Deep learning removes even that step.
Deep learning algorithms — many layers, finding everything automatically
A deep learning algorithm is a machine learning algorithm that stacks many layers on top of each other — like peeling an onion in reverse. Each layer takes what the previous layer found and builds something more complex from it.
Example: Recognising a cat in a photo.
Layer 1 finds edges — dark lines, light lines.
Layer 2 combines edges into shapes — circles, triangles, curves.
Layer 3 combines shapes into parts — a pointed ear, a round face, whiskers.
Layer 4 combines parts into the answer — “this is a cat.”
No human wrote any of those rules. The algorithm built them itself, layer by layer, by studying millions of cat photos.
This is how ChatGPT works. This is how image generators work. This is how voice assistants understand what you say. Deep learning is the engine behind almost every impressive AI you have heard of.
The limit: deep learning needs enormous amounts of data and enormous computing power. For small problems, a simple ML algorithm or even a programming algorithm is faster, cheaper, and just as good.
Side by side comparison
The three types side by side
Programming algorithm
Who writes the rules: A human writes every step.
What it needs: Clear logic. A human who can think of every case.
Where it works: Calculators, traffic lights, sorting a list, navigation directions.
Where it breaks: Anything too complex for a human to write rules for — faces, language, images.
ML algorithm
Who writes the rules: The machine finds them from labelled examples.
What it needs: Lots of labelled data (examples with correct answers).
Where it works: Spam filters, product recommendations, fraud detection, price prediction.
Where it breaks: When you have very little data, or when the patterns are too complex even for ML.
Deep learning algorithm
Who writes the rules: The machine finds them automatically through many layers.
What it needs: Huge amounts of data and powerful computers (GPUs).
Where it works: Image recognition, speech recognition, language understanding, image generation.
Where it breaks: Small datasets, limited compute, or when you need to explain why the decision was made.
Real-world examples
Not theory — what real teams actually shipped using this technique.
Real examples you use every day
- Every time your phone unlocks by recognising your face — deep learning algorithm.
- Every time Gmail catches a spam email — ML algorithm.
- Every time Google Maps finds the fastest route — programming algorithm.
- Every time Netflix says “because you watched X” — ML algorithm.
- Every time you ask ChatGPT something — deep learning algorithm.
- Every time a calculator adds numbers — programming algorithm.
- The same device in your pocket runs all three types, constantly, without you noticing.
Common misconceptions
What an algorithm is NOT ?
- An algorithm is not magic. It is instructions. If the instructions are wrong, the result is wrong.
- An algorithm is not always AI. A recipe is an algorithm. Sorting cards alphabetically is an algorithm. Most algorithms have nothing to do with AI.
- An algorithm is not a black box by nature — programming algorithms are fully transparent. ML and DL algorithms become harder to interpret as they grow more complex, which is why AI explainability is its own research field.
- An algorithm is not infallible. ML and DL algorithms learn from data. Bad data = bad algorithm.
Frequently asked questions
QUESTION 1 What is an algorithm in simple terms?
ANSWER 1 An algorithm is a set of step-by-step instructions for solving a problem. Think of it as a recipe a recipe tells a cook exactly what to do in what order. An algorithm tells a computer the same thing
QUESTION 2 What is the difference between a programming algorithm and an ML algorithm?
ANSWER 2: A programming algorithm is written by a human who specifies every step. An ML algorithm figures out its own steps by learning from data. You give both a problem — but with a programming algorithm you also give the solution method, while with an ML algorithm you only give examples and let it find the method itself.
QUESTION 3 What is a deep learning algorithm?
ANSWER 3: A deep learning algorithm is a type of ML algorithm that uses many stacked layers to find patterns — like peeling an onion layer by layer. Each layer learns something more complex than the last. It needs a lot of data but can solve problems no human could write rules for, like recognising faces or understanding speech.
QUESTION 4 Is every AI built on algorithms?
ANSWER 4: Yes. Every AI system — from a spam filter to ChatGPT — runs on algorithms.
Sources & further reading
- Knuth, D. (1968). The Art of Computer Programming — the definitive textbook on algorithms.
- Mitchell, T. (1997). Machine Learning — defines ML as programs that improve through experience.
- LeCun, Bengio & Hinton (2015). Deep Learning — Nature. The landmark paper on deep learning.
📬 Get one concept + one use case every Tuesday. Join the newsletter →