What is an algorithm? A finite sequence of unambiguous steps that takes an input and produces an output. That is it. A recipe is an algorithm. So is the long division you learned in school, and so is the procedure for sorting a deck of cards. The word sounds intimidating because it gets used loosely in headlines, but the concept is ordinary.
The Formal Requirements
For something to count as an algorithm, it needs:
- Input — something to work on
- Output — a result
- Definiteness — every step is precisely specified, no guessing
- Finiteness — it terminates
- Effectiveness — each step is actually doable
The finiteness one matters more than it sounds. A procedure that runs forever is not an algorithm, it is a process. And a step like “figure out the best move” is not definite enough to count — you would have to specify how.
Why Efficiency Is the Whole Game
Many algorithms solve the same problem. The interesting question is how the work grows as the input grows, which computer scientists write as big-O notation.
| Complexity | Behavior | Example |
|---|---|---|
| O(1) | Constant time regardless of size | Looking up an array index |
| O(log n) | Doubling input adds one step | Binary search |
| O(n) | Scales linearly | Scanning a list once |
| O(n log n) | Nearly linear | Good sorting: mergesort, quicksort |
| O(n2) | Doubling input quadruples work | Naive comparison sorting |
| O(2n) | Explodes | Brute-force subset problems |
The practical difference is brutal. Searching a sorted list of a million items by checking each one: up to a million comparisons. Binary search: about 20. Same answer, same data, 50,000 times less work.
This is why algorithm choice matters more than hardware in most cases. A better algorithm on a slower machine beats a worse algorithm on a faster one, and the gap widens as data grows.
Sorting Is the Classic Example
Everyone understands sorting, so it is the standard teaching case:
- Bubble sort — repeatedly swap adjacent items out of order. Simple to explain, O(n2), slow.
- Mergesort — split the list in half, sort each, merge. O(n log n), reliable.
- Quicksort — pick a pivot, partition around it, recurse. Usually O(n log n) and very fast in practice, though it degrades to O(n2) on pathological inputs.
Modern languages use hybrids — Timsort in Python and Java, introsort in C++ — that switch strategies depending on how the data actually looks.
Where the Word Gets Misused
In news coverage, “algorithm” has drifted to mean something like “the inscrutable machine deciding things.” That is worth pushing back on:
- An algorithm is not necessarily AI. Binary search is an algorithm and involves no learning whatsoever.
- An algorithm is not automatically neutral. Every one encodes choices about what to optimize, and those choices reflect whoever designed it.
- An algorithm is not inherently unknowable. Most are small enough to read; the opacity usually comes from scale, proprietary code, or machine-learned parameters, not from the concept itself.
When a platform says “the algorithm decided,” the accurate translation is usually “people made design choices about what to rank, and the system executes them at scale.”
Problems That Have No Efficient Solution
That is the honest outer edge of what is an algorithm capable of.
Some problems appear to require exponential time no matter how clever you are. The traveling salesman problem — find the shortest route visiting many cities — is the famous one. Checking a proposed route is fast; finding the best one seems to require trying essentially all of them.
Whether these problems genuinely have no efficient algorithm is the P vs NP question, one of the great unsolved problems in mathematics, with a million-dollar prize attached. Almost everyone suspects P does not equal NP. Nobody has proven it.
In practice, engineers use approximations and heuristics that get close enough, quickly — which is fine, because most real applications do not need the provably optimal answer.
Keep Exploring
- How does machine learning work? — when algorithms learn from data
- What is a neural network? — one particular architecture
- How do search engines work? — algorithms at enormous scale




3 thoughts on “What Is an Algorithm? The Concept Behind Every App”