Skip to main content
Thanks for visiting — take a look around, or let us know what you think.servicesblogget in touchRegister on Mostutor — first 1,000 get 3 months free
GCSE & A-Level Computer Science

Algorithm Basics: Writing Step-by-Step Recipes for Computers

Sudershan SoniBy Sudershan Soni 28 July 2026 5 min read

An algorithm sounds like a computer science buzzword, but it's really just a recipe — a precise, ordered set of steps for solving a problem. The word feels intimidating; the idea isn't. Anyone who's followed a recipe to bake a cake, or given someone step-by-step directions to a house, has already written an algorithm. The hard part of computer science isn't usually the code itself — it's learning to think in steps precise enough that something with zero common sense can follow them exactly.

GCSE core

Why "precise" is the whole game

Tell a human friend "check if the number is even," and they'll instantly know what you mean. Tell a computer the same thing, and it needs an exact, unambiguous test — typically, does dividing the number by 2 leave a remainder of 0? A recipe for a human can say "cook until golden" and rely on judgement; an algorithm has to spell out exactly what "golden" means in a way that can be checked mechanically, every single time, with no room for interpretation.

Start: get a numberIs it even?(n % 2 == 0)noprint "odd"yesprint "even"End

An algorithm is a precise set of steps — get a number, test a condition, then follow exactly one of two paths depending on the answer. No guessing, no judgement calls.

Flowcharts and pseudocode: planning before code

Before writing real code, programmers often sketch the algorithm first — either as a flowchart (boxes and arrows showing the logic visually) or as pseudocode (plain-English steps written in a code-like structure). Both exist for the same reason: it's far easier to spot a logic mistake — a missing case, a step in the wrong order — in a simple diagram or a few lines of pseudocode than buried inside actual syntax. Planning the algorithm and writing the code are genuinely two separate skills, and conflating them is a common reason students find early programming confusing.

Exam-style question

A programmer writes an algorithm to find the largest number in a list, but it fails when given an empty list. Explain why this happens, and describe how the algorithm should be changed to handle it. [3 marks]

Show model answer and mark breakdown
  1. The algorithm likely starts by assuming the first item in the list is the current largest, then compares the rest — but an empty list has no first item to start from (1 mark)
  2. A computer follows its instructions exactly as written and has no way to notice this problem unless it was explicitly told to check for it (1 mark)
  3. The algorithm should first check whether the list is empty and handle that case separately (for example, returning an error message) before attempting any comparison (1 mark)

Examiner focus: identify specifically why the empty-list case breaks the algorithm's normal assumption — 'there's no first item to start from' — rather than just saying 'it doesn't work'.

Common mistake: describing the fix only as 'add error handling' without saying what condition needs to be checked and why it matters for this particular algorithm.

Why edge cases matter more than the main case

A working algorithm for the typical case is usually the easy part. The skill that separates a reliable algorithm from a fragile one is thinking through what happens at the edges: an empty list, a negative number where only positives were expected, a search for something that doesn't exist at all. A computer will follow broken instructions just as faithfully as correct ones — it has no way to notice something's gone wrong unless the algorithm was written to check for it. If algorithms, flowcharts or programming logic need explaining as a way of thinking rather than syntax to memorise, that's exactly what our GCSE computer science tutoring is for — see the full learning pathway here.

Frequently asked questions

Is an algorithm the same thing as code?

No — an algorithm is the plan; code is one specific way of writing that plan in a language a computer can run. The same algorithm (say, sorting a list smallest-to-largest) can be written in Python, Java, or plain English pseudocode, and it's still the same algorithm underneath.

Why do algorithms need to handle edge cases like an empty list?

Because a computer will follow the instructions exactly as written, with zero common sense to fall back on — if an algorithm assumes there's always at least one item and it gets an empty list instead, it will typically crash or misbehave rather than 'realising' something's unusual, unless the algorithm was explicitly written to check for that case.

What's the difference between a flowchart and pseudocode?

They're two different ways of describing the same algorithm before writing real code — a flowchart shows the logic visually with boxes and arrows, which is easier to follow at a glance, while pseudocode writes it out in plain, structured, code-like steps, which is closer to what the final program will actually look like.

Reader ratings & reviews

Rate this article across a few different things — your rating helps other readers, and helps us improve.

Content
Images
Presentation
Language clarity
Usefulness

0/3000

Was this article helpful?

Tell us what you think — a correction, a question it left unanswered, or a topic you'd like covered next.

Prefer To Talk? Book a free video call at a time that suits you: 15 minutes for a quick question, 30 for anything else. Times show in your own time zone.

Sudershan Soni

About the author

Sudershan Soni

Founder & Lead Tutor at Mostak Services — an MSc-qualified Mathematics, Science, Computer Science & STEM tutor with 20+ years of professional experience, teaching students from 11+ and GCSE to A-Level and beyond, online worldwide.

Read full profile

Want computer science that builds real understanding?

One-to-one lessons build the logic first, then the syntax. Book a free discussion and we'll show you how.