TopMyGrade

GCSE/Computer Science/OCR

2.1.2Designing, creating and refining algorithms: pseudocode, flowcharts and trace tables

Notes

Designing and refining algorithms

OCR J277 Paper 2 always includes algorithm-design questions. You need to be fluent in both pseudocode and flowcharts, and able to use a trace table to follow what an algorithm does step-by-step.

Pseudocode (OCR Reference Language)

Pseudocode is a structured English-like notation. OCR provides a Reference Language guide; the key conventions are:

  • Assignment uses ← (or = in the exam where ← is unavailable). Example: total ← 0
  • Selection uses IF … THEN … ELSE … END IF.
  • Iteration uses FOR i ← 1 TO n … NEXT i, or WHILE … END WHILE, or DO … UNTIL.
  • Input/output: INPUT and OUTPUT (or PRINT).
  • Subroutines: FUNCTION name(parameters) … RETURN value … END FUNCTION; PROCEDURE name(parameters) … END PROCEDURE.

Flowcharts

SymbolMeaning
Oval (terminator)START / END
ParallelogramINPUT / OUTPUT
RectangleProcess (assignment / calculation)
DiamondDecision (yes / no, true / false)
ArrowFlow of control

A flowchart must have exactly one START and at least one END. Decision diamonds always have two outgoing arrows labelled with the conditions.

Trace tables

A trace table records the value of each variable after each step of an algorithm. Columns = variables (and any output); rows = steps.

Example — pseudocode (single-line form): total ← 0; FOR i ← 1 TO 3 do total ← total + i; NEXT i; OUTPUT total

StepitotalOUTPUT
Start0
Loop i = 111
Loop i = 223
Loop i = 336
OUTPUT total6

Refining algorithms

After a first version, look for:

  • Correctness — does it produce the right output for normal, boundary and invalid inputs?
  • Efficiency — fewer steps, fewer variables, better data structure.
  • Readability — meaningful identifiers, comments, broken into subroutines.
  • Reusability — can a block be lifted into a function called from elsewhere?

Common OCR exam mistakes

  • Using the wrong flowchart shape (rectangle for a decision, etc.).
  • Forgetting to fill the trace table row when a variable changes mid-loop.
  • Using "IF" without a matching "END IF", or "WHILE" without "END WHILE".
  • Designing an algorithm with no terminating condition — the loop never ends.

AI-generated · claude-opus-4-7 · v3-ocr-computer-science-leaves

Practice questions

Try each before peeking at the worked solution.

  1. Question 14 marks

    Trace table

    Trace the following algorithm written in OCR Reference Language and complete a trace table for the variables x, y and the OUTPUT.

    Algorithm (single-line): x ← 5; y ← 0; WHILE x > 0 do y ← y + x; x ← x - 2; END WHILE; OUTPUT y

    [4 marks]

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-ocr-computer-science-leaves

  2. Question 26 marks

    Pseudocode design

    Write pseudocode in OCR Reference Language for an algorithm that:

    • inputs ten numbers from the user,
    • counts how many of them are negative,
    • outputs the count.

    [6 marks]

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-ocr-computer-science-leaves

  3. Question 34 marks

    Flowchart symbols

    State the meaning of each of the following flowchart symbols:
    (a) Oval [1]
    (b) Parallelogram [1]
    (c) Diamond [1]
    (d) Rectangle [1]

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-ocr-computer-science-leaves

Flashcards

2.1.2 — Designing, creating and refining algorithms: pseudocode, flowcharts and trace tables

7-card SR deck for OCR Computer Science (J277) — leaves batch 1 topic 2.1.2

7 cards · spaced repetition (SM-2)