BTS Magazine

What Is an Algorithm? Definition, Types and Everyday Examples

Network of connected points and lines

Photo via Unsplash

A beginner-friendly guide to algorithms: what they are, their characteristics, how they are written and measured, the main types, everyday and computer examples, and why they matter.

Quick answer: An algorithm is a finite set of clear, step-by-step instructions for solving a problem or completing a task. It takes an input, follows defined steps and produces an output. A recipe, the steps for long division and the process a map app uses to find the fastest route are all algorithms. In computing, algorithms are written as code so computers can sort data, search information, recommend content, encrypt messages and train artificial intelligence.

The word “algorithm” appears everywhere: in news about social media feeds, search engine rankings, stock trading and artificial intelligence. It can sound mysterious, but the idea is simple and much older than computers.

This guide explains what an algorithm is in plain language, what makes a good algorithm, the main types you will hear about, everyday and technical examples, and how programmers design and compare algorithms. Whether you are a student, a professional or simply curious, you will finish with a solid understanding of the concept.

In this article

What is an algorithm in simple terms?

An algorithm is a precise recipe for solving a problem. It describes exactly what to do, in what order, and when to stop. The term comes from the name of the 9th-century Persian mathematician Muhammad ibn Musa al-Khwarizmi, whose works introduced systematic methods for arithmetic and algebra to later generations.

Every algorithm has three parts:

Example
Making a cup of tea is an algorithm: boil water, place a tea bag in a cup, pour the water, wait three to five minutes, remove the bag, add milk if wanted. Clear steps, a defined order and a finished result.

What are the characteristics of a good algorithm?

Characteristic Meaning
Finiteness It must finish after a limited number of steps
Definiteness Each step is clear and unambiguous
Input It accepts zero or more defined inputs
Output It produces at least one result
Effectiveness Each step is simple enough to actually be carried out
Correctness It produces the right answer for all valid inputs
Efficiency It uses time and memory sensibly

These properties, described in classic computer science texts, separate a true algorithm from a vague set of suggestions.

How do algorithms work in computers?

Programmers first design an algorithm, often as plain-language steps, a flowchart or pseudocode (a simplified mix of English and code). They then write it in a programming language such as Python, Java or C++. The computer executes the instructions extremely quickly, processing millions of steps per second.

Example
A simple algorithm to find the largest number in a list: (1) set “largest” to the first number; (2) look at each remaining number; (3) if it is bigger than “largest”, replace “largest” with it; (4) when the list ends, return “largest”.

The same algorithm can be written in many programming languages. The algorithm is the idea; the code is one way of expressing it.

What are the main types of algorithms?

Type How it works Example use
Search algorithms Find an item in a collection Linear search, binary search
Sorting algorithms Arrange data in order Bubble sort, merge sort, quicksort
Recursive algorithms Solve a problem by calling themselves on smaller parts Factorials, tree traversal
Divide and conquer Split a problem, solve parts, combine results Merge sort
Greedy algorithms Make the best local choice at each step Making change with the fewest coins
Dynamic programming Store answers to sub-problems to avoid repeats Shortest paths, sequence alignment
Graph algorithms Work with networks of connected points Dijkstra’s shortest path for maps
Encryption algorithms Scramble data so only authorised parties can read it AES, RSA
Machine learning algorithms Learn patterns from data to make predictions Recommendations, image recognition

What are everyday examples of algorithms?

Example
When you search for a café on a map app, an algorithm compares possible routes, estimates traffic and walking times, and returns the quickest option within a fraction of a second.

Algorithms that learn from data are the foundation of modern AI. Our guide to what agentic AI is shows how they are now used to plan and take actions.

How is algorithm efficiency measured?

Computer scientists compare algorithms using Big O notation, which describes how running time or memory grows as the input gets larger.

Big O Name Example
O(1) Constant time Reading one item from an array by position
O(log n) Logarithmic Binary search on a sorted list
O(n) Linear Checking every item in a list
O(n log n) Linearithmic Merge sort
O(n²) Quadratic Bubble sort on large lists

An algorithm that works fine for 100 items may become painfully slow for 100 million. That is why efficiency matters for apps with large numbers of users. Logic and binary operations at the hardware level are covered in our guide to logic gates.

How do you write an algorithm?

  1. Understand the problem clearly and define the expected input and output.
  2. Break the problem into small steps.
  3. Write the steps in order using plain language or pseudocode.
  4. Add decisions (if/else) and loops (repeat) where needed.
  5. Test the steps on sample inputs, including edge cases such as empty lists.
  6. Improve efficiency if the algorithm is too slow.
  7. Translate it into a programming language and test again.
BTS Magazine Tip
Before coding, explain your algorithm out loud or on paper to someone else. If they can follow it without questions, your steps are clear enough to program.

Can algorithms be biased or harmful?

Yes. Algorithms follow rules and data created by people. If the data reflects past unfairness, or if goals are poorly chosen, results can be biased, for example in hiring, lending or content moderation. Social media algorithms optimised only for engagement may spread sensational content. That is why transparency, testing and human oversight matter. Frameworks from organisations such as the OECD AI Principles encourage fair and accountable systems.

Try this today
Write down the steps you follow every morning before leaving home. Number them, add any “if” decisions (if it is raining, take an umbrella) and you have written your first algorithm.

Frequently Asked Questions

What is an algorithm in simple words?

A step-by-step set of instructions for solving a problem or completing a task.

Is an algorithm the same as a program?

No. An algorithm is the idea or method; a program is that method written in a programming language for a computer to run.

Who invented the algorithm?

Step-by-step methods are ancient, but the word comes from the name of the Persian mathematician al-Khwarizmi.

What is an example of an algorithm in daily life?

Following a recipe, tying shoelaces, or the steps you take to get ready for work are everyday algorithms.

What is the most famous algorithm?

Well-known examples include binary search, quicksort, Dijkstra’s shortest-path algorithm and Google’s original PageRank.

Do I need maths to learn algorithms?

Basic logic and arithmetic are enough to start. More advanced algorithm analysis uses discrete mathematics.

Final Thoughts

Explore More on BTS Magazine

Exit mobile version