What Is an Algorithm? Explained with Everyday Examples
What Is an Algorithm?
The word algorithm sounds fancy, but it's simple: an algorithm is a clear list of steps that solves a problem.
You already know lots of algorithms:
- a recipe for tea,
- directions from your home to school,
- the steps to tie your shoelaces.
Each one has a goal, and steps that reach it.
Algorithm vs program
What's the difference? An algorithm is the plan. It can be written in plain words, on paper or in your head. A program is the same plan written in a programming language, so a computer can follow it.
| Algorithm | Program | |
|---|---|---|
| What it is | The steps to solve a problem | Those steps in code |
| Written in | Any language, even plain English | A programming language like Python |
| Who follows it | A person or a computer | A computer |
That's why programmers often write the algorithm first. Once the steps are clear, writing the code is just translating them, like translating a sentence from English to another language.
Every algorithm has
- A start: what you have at the beginning (water, tea leaves, a cup).
- Steps: clear actions, in order.
- An end: the result you wanted (a cup of tea), after which the steps stop.
An algorithm is the plan. A program is that plan written in code.