WHAT IS AN ALGORITHM? – DEFINITION

An algorithm is a well-defined, precise, finite set of steps for solving a problem.

What do those words mean?

  • Well-defined and precise: each step is clear and exact. The person (or computer) following it never has to guess what to do.
  • Finite: the algorithm must end. It cannot go on forever.
  • Steps: the instructions are carried out one at a time, in the correct order.

Algorithms in everyday life

You already use algorithms every day. A recipe is an algorithm! Here is an algorithm for making a cup of tea:

  1. Boil some water. (Ask an adult to help with hot water.)
  2. Put a teabag into a cup.
  3. Pour the hot water into the cup.
  4. Wait 3 minutes.
  5. Take out the teabag.
  6. Add milk and sugar if you like.
A teabag being lifted out of a white cup of tea
Step 5: take out the teabag. Credit: Pasi Mammela, CC BY-SA 2.0, via Wikimedia Commons

Notice that the steps are clear, they are in order, and they end with a cup of tea. That makes it an algorithm.

Ways to write an algorithm

  • Narrative: the steps are written in ordinary sentences, like a story.
  • Pseudocode: the steps are written in short, code-like statements such as IF, THEN and PRINT.
  • Flowchart: the steps are drawn as shapes joined by arrows.

Here is a simple flowchart for fixing a lamp that does not work. Follow the arrows from the top. The diamond shapes are questions: you go one way for “Yes” and another way for “No”.

Flowchart: Lamp doesn't work. Lamp plugged in? No: plug in lamp. Yes: Bulb burned out? Yes: replace bulb. No: repair lamp.
A flowchart for a lamp that doesn’t work. Credit: Booyabazooka (SVG) and Wapcaplet (original PNG), CC BY-SA 3.0, via Wikimedia Commons

Related lessons on this site

Quick check

  1. What does it mean for an algorithm to be finite?
  2. Write an algorithm, as numbered steps, for brushing your teeth.
  3. Name three ways to write an algorithm.

Attributions to media used in this post

© 2020 Vedesh Kungebeharry. All rights reserved.

Updates to this post: October 2026 – Added explanations, examples, a flowchart and a quick check.

Leave a Reply