TopMyGrade

GCSE/Computer Science/AQA

CS1.1Representing algorithms: pseudo-code, flowcharts, written descriptions; comparing algorithms for the same problem

Notes

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:

  1. Ask the user for three numbers.
  2. Set "largest" to the first number.
  3. If the second number is larger, update "largest".
  4. If the third number is larger, update "largest".
  5. 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 mistakesPitfalls

  1. Forgetting the loop counter increments inside a WHILE.
  2. Mixing user input and assignment — USERINPUT n reads from the user, SET n TO 5 does not.
  3. Drawing a flowchart with a decision having only one outgoing arrow.
  4. Confusing "more efficient" (fewer steps) with "shorter to write".
  5. 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

Practice questions

Try each before peeking at the worked solution.

  1. Question 16 marks

    Three constructs

    Name and briefly describe the three control-flow constructs used in any algorithm.

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-deep-computer-science

  2. Question 23 marks

    Pseudocode for sum

    Write AQA pseudocode that asks the user for two numbers, adds them, and outputs the result.

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-deep-computer-science

  3. Question 34 marks

    Flowchart symbols

    State the meaning of each flowchart symbol: (a) rounded rectangle, (b) parallelogram, (c) rectangle, (d) diamond.

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-deep-computer-science

  4. Question 43 marks

    Compare two algorithms

    For a list of 1000 items, algorithm A makes up to 1000 comparisons and algorithm B makes up to 10 comparisons. Explain which is more efficient and what assumption B might rely on.

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-deep-computer-science

  5. Question 54 marks

    Translate to pseudocode

    Convert the following description to AQA pseudocode: "Ask the user for a number n, then output every multiple of 3 from 3 up to and including n."

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-deep-computer-science

  6. Question 64 marks

    Trace a small algorithm

    Trace the output of this pseudocode:

    SET x TO 0
    FOR i FROM 1 TO 4
      SET x TO x + i
    ENDFOR
    OUTPUT x
    
    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-deep-computer-science

  7. Question 73 marks

    Off-by-one bug

    A pupil writes:

    FOR i FROM 1 TO 10
      OUTPUT i
    ENDFOR
    

    They expect 9 numbers but get 10. Explain.

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-deep-computer-science

Flashcards

CS1.1 — Representing algorithms — pseudocode and flowcharts

12-card SR deck for AQA GCSE Computer Science topic CS1.1

12 cards · spaced repetition (SM-2)