DASKEREL published · Year 10 · academic review pending

Computer Science GCSE

Original DASKEREL teaching informed by an attributed Oak unit sequence. This resource remains subject to qualified academic review. Check your examination board and tier before using it for exam preparation.

Year 10 · Original DASKEREL study pack · Academic review pending

Design and trace an algorithm before coding

Allow up to 60 minutes for reading, practice and review · Source route: Oak AQA Computer Science · DASKEREL teaching requires board review

DASKEREL wrote this resource using the Oak National Academy unit sequence as a curriculum reference. It is a study pack, not a complete unit or an exam-board-approved course. Academic review remains pending.

You will learn to

  • Specify inputs, processing and outputs for a small problem.
  • Trace an algorithm using a state table.
  • Test normal, boundary and invalid inputs and repair a logic fault.

Key terms: algorithm · pseudocode · trace table · boundary · invariant

Learn the idea

An algorithm is a finite, unambiguous procedure for a task. Start with the problem contract: what inputs are accepted, what output is required and what rules must always hold. A flowchart or pseudocode communicates logic independently of a programming language.

A trace table records the value of each relevant variable after each step or loop iteration. It makes hidden state visible. Trace the condition exactly as written: an off-by-one error may appear only at the boundary.

A useful test set contains a normal value, each meaningful boundary and an invalid input. Expected results must be chosen before execution so a program cannot define its own success. If a result is wrong, identify the first trace row that departs from expectation.

When a loop scans a non-empty list for the largest value, initialise the current largest from the first element rather than 0 unless nonnegative data is guaranteed. Handle an empty list explicitly before accessing its first element. The maintained statement ‘largest equals the maximum of all items seen so far’ explains why the algorithm works.

Worked example

Trace a largest-value algorithm on [-4, -7, -2]. Start largest = first item; then compare each remaining item and replace largest when item > largest.

  1. Before the loop, largest = -4.
  2. Compare -7 > -4: false, so largest stays -4.
  3. Compare -2 > -4: true, so largest becomes -2.
  4. There are no more items; output largest = -2.
  5. Test an all-negative list because initialising largest to 0 would have produced an incorrect answer.

The algorithm outputs -2, the greatest list value.

Try together

Trace the same rule on [5, 9, 9, 1], writing largest after each comparison.

  • Initial value is the first item.
  • The update uses >, not >=; the numerical result is unchanged for a tie.
  • Record all three comparison outcomes.
Show guided answer

Initial 5; after comparing 9, 9, 1 the values are 9, 9, 9. Output 9.

Practise independently

  1. Why does initialising largest = 0 fail on [-3, -8, -1]? Give a repair.
    Show answer and reasoning for question 1

    It would incorrectly output 0; initialise from the first element, giving -1 after the trace. Zero is not in the list and exceeds every negative entry.

  2. Design a test set covering normal, boundary and invalid inputs for an algorithm that accepts integers 1 through 10 inclusive and rejects all others.
    Show answer and reasoning for question 2

    For example 5 (normal accept), 1 and 10 (boundary accept), 0 and 11 (outside boundary reject). A complete set checks the middle, both permitted edges and both immediate invalid neighbours.

  3. Trace a running-total algorithm starting at 0 as it adds [3, 0, -2, 5]. Give the total after each item.
    Show answer and reasoning for question 3

    3, 3, 1, 6; final output 6. Add each item to the previous state: 0 + 3 = 3, then + 0 = 3, then - 2 = 1, then + 5 = 6.

DASKEREL exam-style practice · 6 draft marks

This original practice task and guidance are not an official examination-board paper or mark scheme.

Write pseudocode to count how many values in a list of eight integers exceed 20. Show a trace for [21, 20, 25, 0, -1, 40, 19, 22] and name one boundary test.

Show draft mark guidance
  • Initialise count to zero (1).
  • Iterate over all eight values (1).
  • Use a strict > 20 comparison (1).
  • Increment count only when true (1).
  • Trace or output count = 4 for the stated list (1).
  • Identify 20 as a boundary test that must not count (1).

Check your understanding

  • A trace table records changing state, not merely the final answer.
  • ‘Greater than 20’ excludes 20; replacing > with >= changes the boundary.
  • A test that reuses only normal values is unlikely to expose an edge fault.

Retrieve later: Why must expected output be decided before running the algorithm?

Next step: Implement the traced algorithm in Python and compare the same test evidence with the design.

Library links: Oak National Academy · Algorithms (checked 2026-11-06) · DASKEREL subject library. Oak's applicable post-2022 content licence is OGL v3.0; some source assets have separate third-party rights. No Oak media is embedded here. DASKEREL is not affiliated with Oak.