What Makes a Good Algorithm
A well-designed algorithm must satisfy four properties. It must be correct (right output for any valid input), efficient (minimal time and memory), clear (each step unambiguous), and finite (it must eventually terminate).
Everyday examples
A recipe is an algorithm: a fixed sequence of steps that produces a defined result if followed correctly. A morning routine — wake, shower, dress, eat — is an algorithm. A decision tree ('if it is raining, take an umbrella; otherwise, don't') is a simple conditional algorithm.
How algorithms are measured
Efficiency is measured using time complexity — how the number of steps grows as input gets larger. An algorithm that sorts ten items quickly might take billions of steps to sort a million. Choosing the right approach for the task is one of the core skills in computer science. Coding is the practice of translating algorithms into a language a computer can execute.
Algorithms in everyday computing
Search engines use ranking rules to decide which pages appear first. GPS apps use shortest-path rules (like Dijkstra's algorithm) to find efficient routes. Social media platforms use recommendation rules to decide what content you see. Machine learning algorithms learn from data rather than following fixed rules — but they are still algorithms.
Types of Algorithms
Computer scientists group these problem-solving procedures into families based on their approach.
Sorting and searching
Sorting procedures arrange data in order — bubble sort, merge sort, and quicksort are classic examples. Searching procedures locate items in data — binary search halves the search space with each step. This makes it far faster than checking every item in sequence.
Divide and conquer
This strategy breaks a large problem into smaller sub-problems, solves each, and combines the results. Merge sort works this way: it splits a list in half repeatedly until individual items remain, then merges them back in order.
Greedy approaches
A greedy strategy makes the locally best choice at each step without reconsidering past decisions. Greedy approaches are fast but do not always find the globally best solution — they work well for some problems and poorly for others.
Recursive approaches
A recursive procedure calls itself with a simpler version of the problem. Calculating a factorial (5! = 5 × 4 × 3 × 2 × 1) is naturally recursive: factorial(n) = n × factorial(n−1).
Algorithms and Society
The procedures running on computers have real consequences for people's lives — and understanding this is essential for digital citizenship.
Bias in automated decision-making
An algorithm trained on biased data will reproduce that bias. Hiring tools, loan-approval systems, and predictive policing programs have all been found to discriminate against particular groups. Not through intent, but because historical data encoded historical inequalities.
Transparency and accountability
Many decision-making procedures used in high-stakes areas — credit scoring, medical diagnosis, criminal sentencing — are not publicly disclosed. When a decision-making system affects your life, understanding what rules it follows and who is responsible for its errors matters enormously.
Filter bubbles
Recommendation procedures on social media are optimised to maximise engagement — which often means showing content that provokes strong reactions. This can create filter bubbles where users see only information that reinforces their existing views. Understanding that these feeds are curated by profit-driven rules is a key part of digital literacy.
Frequently asked questions
- What is the difference between an algorithm and a program?
- An algorithm is a logical procedure — a sequence of steps described in plain language or pseudocode. A program is the implementation of that procedure in a specific programming language that a computer can run. The same algorithm can be implemented in many different languages. Designing the approach is done first; writing the code comes after.
- Do algorithms always give the right answer?
- A correctly designed algorithm gives the right answer for any valid input it was designed for. But algorithms can fail when they encounter inputs they were not designed to handle, when the design has a bug, or when the problem they are solving is defined incorrectly.
- Why do some algorithms take longer than others?
- The time an algorithm takes depends on how many steps it needs as input grows. Checking every item takes twice as long when a list doubles. Halving the problem each step is far faster. Choosing the right approach can mean the difference between seconds and years.
- Can algorithms be creative?
- Algorithms can generate text, images, music, and code that appear creative — but they do so by finding patterns in existing data, not through understanding or intent. Generative AI systems follow complex statistical procedures to produce outputs that resemble human creative work. Whether this constitutes genuine creativity is debated by philosophers and researchers.