Representing algorithms
An algorithm is a step-by-step description of how to solve a problem. It is independent of any programming language: the same algorithm can be coded in Python, Java or AQA pseudocode. GCSE Computer Science exams use three notations to express algorithms — pseudocode, flowcharts and structured English (written descriptions).
AQA pseudocode
AQA publishes a pseudocode reference (you'll get a copy in the exam). Key syntax to memorise:
SET name TO value
IF condition THEN ... ELSE ... ENDIF
WHILE condition ... ENDWHILE
FOR i FROM 1 TO 10 ... ENDFOR
OUTPUT name
USERINPUT
LEN(s), POSITION(s, c), SUBSTRING(start, end, s)
Indentation isn't required for marks, but it helps the examiner follow the structure (and helps you avoid mistakes).
Example — pseudocode for the largest of three numbers:
USERINPUT a
USERINPUT b
USERINPUT c
SET largest TO a
IF b > largest THEN
SET largest TO b
ENDIF
IF c > largest THEN
SET largest TO c
ENDIF
OUTPUT largest
Flowcharts
Flowcharts use a small symbol library:
- Rounded rectangle (terminator) — Start / Stop.
- Parallelogram — input or output.
- Rectangle — process (calculation, assignment).
- Diamond — decision (yes/no question).
- Arrows — flow of control.
Decisions always have exactly two outgoing arrows (yes and no), labelled clearly. Flowcharts are good for showing the overall control flow but are clumsy for long programs.
Written descriptions (structured English)
Plain English numbered steps:
- Ask the user for three numbers.
- Set "largest" to the first number.
- If the second number is larger, update "largest".
- If the third number is larger, update "largest".
- Output "largest".
Useful for designing an algorithm before you code it, but exams expect pseudocode for any non-trivial questions.
Comparing algorithms for the same problem
You'll often see two algorithms that solve the same problem but in different ways. The exam might ask "which is more efficient?" — meaning fewer comparisons or fewer steps for the worst case.
Example. Finding if a number is in a list:
- Algorithm A — check items 1, 2, 3, … in turn (linear search).
- Algorithm B — check the middle item, then halve the search range (binary search, requires sorted list).
For a list of 1024 items, A might take up to 1024 comparisons; B takes at most 10. They give the same output but B is far more efficient — if the precondition (sorted list) is met.
Translating between representations
You should be able to convert any algorithm between pseudocode, flowchart and written description. The trick is to identify three constructs:
- Sequence — straight-line flow.
- Selection — IF / ELSE branches (diamond in a flowchart).
- Iteration — WHILE / FOR loops (loop arrow in a flowchart).
Every algorithm is built from these three constructs, however complex.
⚠Common mistakes— Pitfalls
- Forgetting the loop counter increments inside a WHILE.
- Mixing user input and assignment —
USERINPUT nreads from the user,SET n TO 5does not. - Drawing a flowchart with a decision having only one outgoing arrow.
- Confusing "more efficient" (fewer steps) with "shorter to write".
- Off-by-one errors at boundary conditions (FOR i FROM 1 TO 10 runs 10 times — not 9 or 11).
Quick worked example
Convert this written description to pseudocode and a flowchart in your head: "Repeatedly add numbers entered by the user until the user enters 0; then output the running total."
SET total TO 0
USERINPUT n
WHILE n != 0
SET total TO total + n
USERINPUT n
ENDWHILE
OUTPUT total
The flowchart would have a single decision diamond ("n = 0?") with the no branch looping back through a process and an input box, and the yes branch heading to an output and stop terminator.
AI-generated · claude-opus-4-7 · v3-deep-computer-science