What Is an Algorithm? Explained Simply

An algorithm is a finite, well-defined sequence of steps that solves a problem or performs a computation. Learn the concept with a simple sorting example.

Published September 22, 2026

An algorithm is a finite, step-by-step procedure for solving a problem or completing a task, such as a recipe. Good algorithms are correct, efficient and clear.

The concept

It takes input, follows unambiguous steps and produces output, and it must end. The same problem can have many algorithms with different speed and memory costs.

We compare them with Big O notation. For example, finding a name in a sorted list by binary search beats checking every entry.

Finding the largest number

  1. Assume the first number is the largest
  2. Look at the next number
  3. If it is bigger, remember it
  4. Repeat until the end, then report the remembered number

Practical examples

Max of a list

def maximum(nums):
    best = nums[0]
    for n in nums[1:]:
        if n > best:
            best = n
    return best

Linear search

def find(nums, t):
    for i, n in enumerate(nums):
        if n == t: return i
    return -1

Everyday algorithm

Make tea: boil water → add tea → wait 3 min → remove bag → serve

Common mistakes

  • Skipping edge cases such as empty input.
  • Ignoring efficiency for large data.
  • Writing code before understanding the steps.

Key takeaways

  • Algorithm = precise steps to a result.
  • Judge by correctness and efficiency.
  • Plan the steps before coding.

FAQ

Algorithm vs program?

The algorithm is the idea; the program is its implementation in a language.

Where do I start learning?

Sorting, searching, recursion and basic data structures.

More General articles