Quick Answer
An algorithm is a finite, well-defined sequence of steps that takes an input and produces an output. It is a recipe for solving a problem. Computers follow algorithms to sort lists, search for files, recommend videos, and power AI. The steps must be clear enough that following them mechanically, without guessing, always reaches a result.
Five dark discs connected in a circular cycle by red links. No em-dashes.
An algorithm runs as an ordered cycle of steps, where each instruction hands off cleanly to the next.

What an algorithm is

An algorithm is a set of instructions for getting something done. You give it an input, it follows its steps in order, and it returns an output. That is the whole idea.

You use algorithms every day without naming them. Making coffee, tying your shoes, and following directions home are all step-by-step procedures. Each one takes a starting point and produces a finished result.

Computers need this kind of precision. A computer cannot improvise or read between the lines. It does exactly what the steps say, in the exact order given. So an algorithm written for a computer has to spell out every step with no gaps.

The word “input” means the information the algorithm starts with. The word “output” means the result it produces. A search algorithm takes your query as input and returns a list of pages as output.

Input Starting data A list, a number, a search query, or any information to work on.
Step First instruction A clear action, such as compare two items or pick the middle one.
Step Next instruction Repeat, decide, or move on based on the previous result.
Output Finished result The answer: a sorted list, a found item, or a yes or no.

A recipe and a set of directions

The clearest analogy for an algorithm is a recipe. A recipe lists ingredients (the input) and a numbered set of steps. Follow the steps in order and you get a dish (the output). Anyone who follows the same recipe carefully reaches the same result.

Directions to a destination work the same way. “Turn left at the bakery, walk two blocks, the office is on your right.” Each instruction is clear. The steps come in order. Follow them and you arrive. That ordered, unambiguous quality is exactly what makes something an algorithm.

A recipe that says “add some flour and bake until done” is a weak algorithm. “Some” and “until done” leave too much to guess. A computer cannot guess. A good algorithm replaces vague words with exact ones: “add 200 grams of flour and bake for 25 minutes”.

The four properties of an algorithm

Standard computer science references describe an algorithm with a small set of properties. Four of them matter most for a beginner.

PropertyWhat it means
1FiniteIt ends. The steps stop after a limited number of actions.
2Well-definedEach step is clear and has one meaning. No guessing.
3Takes inputIt starts with some given information, even if that is nothing.
4Produces outputIt returns a result that solves the problem.

“Finite” means the algorithm does not run forever. A set of steps with no stopping point is not a useful algorithm. A computer that never finishes never gives you an answer.

“Well-defined” means every step has one clear meaning. Two people following the steps do the same thing. A computer reading the steps does the one thing intended, every time.

These properties come from foundational references such as Introduction to Algorithms (often called CLRS after its authors) and Donald Knuth’s The Art of Computer Programming. They are the shared rules that working software depends on.

A worked example: finding a name

Imagine a paper phone book with thousands of names in alphabetical order. You want to find “Okonkwo”. How do you do it?

One algorithm is to start at page one and read every name until you hit a match. This is called linear search. It works, but it is slow. If the name sits near the end, you read almost the whole book.

A smarter algorithm uses the fact that the names are sorted. Open the book to the middle. Is “Okonkwo” before or after the name you see? Throw away the half it cannot be in. Open to the middle of the remaining half. Repeat.

Start
Open to the middle page Compare the target name to the name you see
Decide
Target is earlier Target is later Keep only the half that can hold the name
Repeat
Halve again Each step cuts the remaining pages in half
Finish
Name found One page left, or the name is not present

This second approach is called binary search. Each step throws away half of what is left. A phone book with one million names needs only about 20 steps, not one million. The same problem, a far faster algorithm. You can read more in How Search Algorithms Work .

Why the same problem has many algorithms

The phone book example shows a key idea. One problem can have many algorithms, and they are not equally good. Linear search and binary search both find the name. Binary search does far less work as the data grows.

This difference is the heart of computer science. When data is small, the slow method feels fine. When data grows to millions or billions of items, the choice of algorithm decides whether a program answers in a blink or grinds for hours.

Computer scientists measure this with Big O notation. Big O describes how the number of steps grows as the input grows. Linear search grows in step with the data. Binary search grows far more slowly. Big O Notation explains this language in plain terms.

Speed is not the only thing to compare. Some algorithms use less memory. Some are easier to write correctly. Some handle messy real-world data better. Choosing an algorithm means weighing these trade-offs for your situation.

Algorithms in everyday software and AI

You meet algorithms every time you touch a screen. When a streaming service suggests a film, a recommendation algorithm ranks options for you. When a map app routes you around traffic, a pathfinding algorithm searches for the shortest route. When your photos sort by date, a sorting algorithm orders them.

Search engines run algorithms to rank pages. Banks run algorithms to flag unusual transactions. Online shops run algorithms to decide what to show you next. Each one is a set of steps with an input and an output.

Modern AI is built on algorithms too, with one twist. A traditional algorithm has steps a person wrote by hand. A machine learning algorithm instead learns its own steps from examples in data. The training process that produces the model is itself an algorithm, and the rules it learns guide the answers it gives.

So algorithms range from a five-line recipe to a system trained on huge datasets. The core idea never changes. Take an input, follow clear and finite steps, produce a useful output.

Where the word comes from

The word “algorithm” has a long history. It comes from the Latinized name of Muhammad ibn Musa al-Khwarizmi, a Persian mathematician who lived around 780 to 850. He worked at the House of Wisdom in Baghdad.

Al-Khwarizmi wrote a book explaining the Hindu-Arabic numeral system, the digits 0 to 9 that you use today. European scholars translated it into Latin centuries later. The Latin title carried his name, and “al-Khwarizmi” gradually became “algorithm”, the word for a step-by-step procedure.

The same mathematician gave us another word you know. His work on solving equations was titled with the Arabic word “al-jabr”, which became “algebra”. Two of the most important words in mathematics trace back to one scholar.

What’s next

Further reading