Stewdent.eu
▾

Algorithm

An algorithm is a step-by-step set of instructions for solving a problem or completing a task.

Last updated: 17 November 2025

★☆☆☆☆ Level 1computingglossaryalgorithmsalgorithm3 min read

Report an error

Definition

An algorithm is a finite, ordered sequence of well-defined instructions that solves a problem or achieves a goal. Every time a computer carries out a task — sorting a list, finding a route, compressing a file — it follows an algorithm.

Algorithms are not exclusive to computers. Any precise, step-by-step procedure qualifies.

Real-World Analogy: A Recipe

A cooking recipe is an algorithm:

  1. Preheat oven to 180°C.
  2. Mix flour, sugar, and butter in a bowl.
  3. Add eggs and stir until smooth.
  4. Pour mixture into a baking tin.
  5. Bake for 30 minutes.
  6. Remove from oven and allow to cool.

Like a computer algorithm, a recipe has a defined start, a series of unambiguous steps, and a defined end (a finished cake).

Key Properties of an Algorithm

A valid algorithm must satisfy these properties:

PropertyMeaning
FiniteIt must eventually stop — it cannot run forever
DefiniteEach step is precisely and unambiguously defined
InputIt accepts zero or more inputs
OutputIt produces at least one result
EffectiveEvery step can actually be carried out
Note

An algorithm that never terminates (an infinite loop with no exit condition) is not a valid algorithm, even if every individual step is correct.

A Simple Pseudocode Example

Here is an algorithm that finds the largest number in a list:

DEFINE findMax(numbers):
    max = numbers[0]
    FOR each number IN numbers:
        IF number > max:
            max = number
    RETURN max

Step by step:

  1. Start by assuming the first number is the largest.
  2. Go through every number in the list.
  3. If the current number is bigger than the current maximum, update the maximum.
  4. After checking every number, return the maximum found.

Algorithms vs Programs

An algorithm is an idea — a logical sequence of steps. A program is a specific implementation of that idea in a programming language. The same algorithm can be written in Python, Java, or any other language; the underlying logic remains the same.

Tip

Before writing any code, it is good practice to design the algorithm first — in plain language or pseudocode. This separates the problem-solving thinking from the syntax details of a specific language.

Practice Problems

Name the five key properties that every algorithm must have.

Show answer
Finite (must terminate), Definite (each step is unambiguous), Input (accepts inputs), Output (produces at least one result), Effective (every step is executable).

What is the difference between an algorithm and a program?

Show answer
An algorithm is a logical, language-independent description of a solution. A program is a concrete implementation of that algorithm written in a specific programming language.