An algorithm is a finite, step-by-step procedure for solving a problem or completing a task. It takes an input, follows clear instructions in a specific order, and produces an output. Use the same steps with the same input, and you should get the same result. That pattern — input, ordered steps, output — sits behind recipes, directions, search results, and most software you use every day.
Table of Contents
TL;DR / Key Takeaways
- An algorithm is a step-by-step procedure with a clear start, end, and output.
- Good steps are unambiguous, correctly ordered, and work for every valid input.
- An algorithm is the plan; a program is that plan written in code.
- Building blocks: sequence (in order), selection (if this, then that), repetition (repeat until done).
- Search and feed systems select and rank content — top results are ranked suggestions, not verified truth.
How Does an Algorithm Work?
Every algorithm has three parts. Input is what you start with: a list of names, a destination, ingredients, or a search query. Process is the sequence of steps applied to that input, each clear enough to follow without guessing. Output is the result: a sorted list, a route, a finished dish, or a set of search results.
Here is a worked example — finding the largest number in a list:
- Input: 4, 9, 2. Remember 4 as the largest so far.
- Compare 4 with 9. Since 9 is larger, remember 9 instead.
- Compare 9 with 2. Since 2 is not larger, keep 9.
- The list has ended, so output 9.
Skip the comparison step and you would report the first number; without a stopping rule, the procedure would never finish. A good algorithm also handles edge cases: for an empty list there is no largest number, so it should say so rather than invent an answer.
What Makes a Good Algorithm — and What Breaks a Bad One?
Four qualities separate a working algorithm from vague instructions. It must be finite: it has to finish, so “keep stirring forever” does not qualify. Its steps must be clear and unambiguous: “add 200 grams of flour” can be followed exactly, while “add some flour” cannot, and literal computers will follow a vague step wrongly. Steps must be in the correct order: you cannot bake before mixing. Finally, it must be correct and general, solving the problem for all valid inputs, not only the author’s example.
Test any instructions with four questions: When does it stop? Could a step be read two ways? Is any step out of order? What happens with a missing or unexpected input? If any answer is unclear, fix it before trusting it. Efficiency matters too: two correct algorithms can differ greatly in steps taken, which is invisible for a handful of items but decisive for millions.
What Are the Three Building Blocks of Any Algorithm?
Almost every algorithm is built from three ideas. Sequence means steps follow one after another in a set order, like a recipe. Selection means choosing based on a condition: if it is raining, take an umbrella; otherwise, do not. Repetition means repeating steps until a condition is met: keep comparing pairs of books until a full pass makes no swaps.
To read an unfamiliar procedure, ask: what happens in order, where does it branch, and what repeats?
What Are Some Everyday Step-by-Step Examples?
A recipe is an algorithm for cooking: ingredients are the input, the method is the process, and the dish is the output. Order matters — preheat first, mix, combine, then bake — and a strong recipe gives a doneness test, such as “bake until golden and a skewer comes out clean,” not just “cook until done.”

Giving directions works the same way: start and destination are the input, each turn is a step, and arrival is the output. Good directions include selection — “if the road is closed, take the next left” — because without that branch, one closure breaks the route.
Sorting books alphabetically shows repetition: compare each neighbouring pair, swap any out-of-order pair, and repeat passes until a pass makes no swaps. It is slow, but anyone can follow it, and faster methods rest on the same idea: compare, decide, and move items until the order is right.

What Are the Main Types of Algorithms?
Algorithms are usually grouped by what they do. Use this table as a decision guide: match your problem to the type, and you will know what the algorithm is optimising for.
| Type | What it does | Use it when you need to… |
|---|---|---|
| Search | Find a specific item in a collection | Find a name in contacts or a word in a document |
| Sorting | Put items into a defined order | Arrange prices low to high or names A to Z |
| Recommendation | Suggest items likely to be relevant | Discover a film, article, or product from past choices |
| Navigation | Find a route between two points | Choose a driving route that avoids heavy traffic |
| Compression | Make data smaller | Shrink a photo file so it loads faster |
| Encryption | Scramble data for authorised readers only | Protect a message or payment in transit |
These types often combine in one product: a navigation app may search, plan a route, and rank alternatives.
Is an Algorithm the Same as a Program, an App, or AI?
No. An algorithm is the idea — the step-by-step plan. A program is that plan written in a programming language so a computer can execute it, and the same algorithm can be written in many languages or plain English. An app is a complete product containing dozens of algorithms plus design, data, and settings. AI systems also use algorithms, but they adjust their behaviour based on data and examples, rather than following only fixed rules written in advance.
Check the logic first — are the steps complete, ordered, and able to finish? — because a flawed plan stays flawed in any language. For a gentle next step into turning plans into software, see What Is Python?.
How Do Algorithms Affect Search Results and Feeds?
Search and feed systems use algorithms to decide what to retrieve, how to rank it, and what order to show it in. Search generally matches your query with relevant pages and ranks them by signals such as relevance and usefulness. Feeds generally predict what you are likely to find interesting, based on what you have engaged with before.
Be precise about what is not known: the exact internal workings of any specific company’s system are not public, and this article does not claim to describe them. What can be said generally is that these systems select and order — they are not a neutral mirror of everything available. That is why two people can see different results for the same topic, and why a feed can narrow over time. Ranking is therefore not verification: appearing first means an algorithm ranked a result highly, not that it is correct. Speed also matters, which is why caching — storing a copy of frequently used data for faster retrieval — is so important; read more in What Is Cache?.

Checklist: Think Algorithmically and Stay in Control
Use this checklist for a messy task, and for the feeds and results you see every day.
- Define the problem precisely: state the input and exact output you want.
- Break it into small steps: split any large step until each step is one clear action.
- Add branches for surprises: include “if this, then that” rules for missing or empty inputs.
- Test with a small example: walk through the steps by hand, then fix the failing step.
- Look for repetition: describe a repeated step once, as “repeat until” a condition is met.
- Widen your search inputs: use varied search terms and compare sources beyond the top results.
- Reset a narrowing feed: follow more reliable sources and use “not interested” controls where offered.
- Control what is visible about you: a VPN changes how your connection appears to a network, but does not make you anonymous or change ranking for a logged-in account. See What Is a VPN?.
- Keep learning by building: write instructions for a real task, test them on someone else, then learn a first programming language.
Summary
An algorithm is a finite, step-by-step procedure that turns an input into an output through clear, correctly ordered steps built from sequence, selection, and repetition. You already use algorithms in recipes, directions, and sorting; computers use the same idea at far greater speed and scale. An algorithm is the plan, not the program or the app — and thinking algorithmically makes technology easier to use well and question wisely.
Related Reading
Frequently Asked Questions
What is an algorithm in simple words?
An algorithm is a step-by-step set of instructions for solving a problem or completing a task. It starts with an input, follows clear steps in order, and ends with an output. A recipe is the simplest everyday example.
What is the difference between an algorithm and a program?
An algorithm is the plan, while a program is that plan written in a programming language for a computer to run. The same algorithm can be described in plain English, as a flowchart, or in many different programming languages.
Can an algorithm be wrong or unfair?
Yes. An algorithm can be wrong if a step is missing, badly ordered, or untested on unusual inputs, and it can produce unfair outcomes if its rules or underlying data reflect a narrow view. Testing with varied inputs and questioning rankings are the practical defences.
Do algorithms learn on their own?
Ordinary algorithms do not: they follow fixed steps. Some AI systems use algorithms that adjust based on data and examples, so their behaviour can change over time — but the learning itself still follows a procedure, and the outcome is no longer set in advance.
Why do two people get different search results or feeds?
Because ranking is personalised using signals such as the query, past engagement, and account activity, and content itself changes. Different inputs therefore produce different ranked outputs.