AQA GCSE Computer Science June 2023 Paper 1, Question 5: the flowchart trace table

AQA 8525 June 2023 Paper 1, Question 5: the flowchart trace table worked through one pass at a time, the finished table, where marks are lost, and the same algorithm as a Python program you can run.

Past paper questionAQA 8525/1BJune 2023 Paper 13 marksTrace table

Question 5 of the AQA GCSE Computer Science Paper 1 sat on 19 May 2023 (8525/1B, the Python paper) gives you a flowchart and asks you to complete a trace table for it. It is worth 3 marks. This page works through it one step at a time, shows the finished table, and turns the flowchart into a program you can run to check your own answer.

We do not copy the exam paper here. Open it beside this page: AQA June 2023 Paper 1B question paper (PDF). When you have finished, check the mark scheme too.

The question in short

The flowchart uses three variables: a, b and c.

  1. It starts by setting a to 0 and b to 1.
  2. It adds them and stores the answer in c.
  3. It asks: is c greater than 4?
  4. If no, a takes the value of b, then b takes the value of c, and it goes back to step 2.
  5. If yes, it stops.

The trace table has a column for each variable and eight empty rows. The paper tells you that you may not need them all.

Try it first

Cover the rest of this page and trace it on paper. Three marks, about three minutes. Then check your table against the one below.

Work it through

Go round the loop one pass at a time. On each pass, work out c first, then ask the question, then (only if the answer is no) move the values along.

Pass 1. a is 0 and b is 1, so c is 0 + 1 = 1. Is 1 greater than 4? No. So a becomes 1 (the old b) and b becomes 1 (the c you just worked out).

Pass 2. c is 1 + 1 = 2. Is 2 greater than 4? No. So a becomes 1 and b becomes 2.

Pass 3. c is 1 + 2 = 3. Is 3 greater than 4? No. So a becomes 2 and b becomes 3.

Pass 4. c is 2 + 3 = 5. Is 5 greater than 4? Yes. Stop. a and b do not change again.

The finished trace table

a b c
0 1 1
1 1 2
1 2 3
2 3 5

Four rows are used and four are left empty. Read down each column and you have the order the values were stored in: a is 0, 1, 1, 2. b is 1, 1, 2, 3. c is 1, 2, 3, 5.

You may recognise the numbers in the c column. Each one is the sum of the two before it. This is the Fibonacci sequence, and the flowchart stops at the first Fibonacci number bigger than 4.

Run it

Here is the same flowchart as a Python program. The robot prints one row of the trace table on each pass, then drives forward c centimetres, so you can watch c grow. Check the printed rows against your table. The first row that differs is the step you misread.

LIMIT = 4: four passes. The robot prints 0 1 1, then 1 1 2, then 1 2 3, then 2 3 5, and stops because 5 is greater than 4.
The program
from bugbot import *
connect()

# change LIMIT and press Run
LIMIT = 4

a = 0
b = 1
while True:
    c = a + b
    print(a, b, c)             # one row of the trace table
    plot("c", c)
    forward(60, distance=c)    # drive c centimetres
    if c > LIMIT:
        break                  # yes: stop
    a = b                      # no: move the values along
    b = c
Put this demo on your own site

Paste it into a school website, Moodle, Google Sites or a blog. More options on the embed page.

The flowchart tests at the bottom of the loop, after c has been worked out. That is why the Python uses while True with a break. A plain while c <= 4 at the top would need c to have a value before the loop starts.

Where the marks are lost

The usual slips on this kind of question:

  • Stopping a pass early. c reaches 3 and it feels finished. It is not: 3 is not greater than 4, so there is one more pass.
  • Going one pass too far. After c becomes 5 the answer to the question is yes, so nothing else changes. Writing a = 3 and b = 5 in a fifth row is wrong.
  • Updating b before a. The box says a takes b first, then b takes c. If you do it the other way round, a gets the new b and every row after that is wrong.
  • Forgetting the starting values. The first things stored are 0 in a and 1 in b. They belong in the table.
  • Filling every row. Eight rows are printed and four are needed. Empty rows are fine. The paper says so.

How the three marks are shared out: one for the first row, one for the second row, and one for the third and fourth rows together. Any error caps you at two. The mark scheme accepts values written on different rows, so long as the order down each column is clear, so the order matters more than the exact row.

Now change it

Change LIMIT to 20 and trace it on paper before you press Run. How many rows will the table need, and what is the last value of c?

Answer Seven rows. The values of c are 1, 2, 3, 5, 8, 13 and 21, and 21 is the first one greater than 20.

Questions

What is the answer to AQA GCSE Computer Science 2023 Paper 1 Question 5?

The trace table has four rows. Reading across, they are: a = 0, b = 1, c = 1. Then a = 1, b = 1, c = 2. Then a = 1, b = 2, c = 3. Then a = 2, b = 3, c = 5. The algorithm stops there because 5 is greater than 4.

What does the flowchart in Question 5 do?

It makes the Fibonacci sequence, where each number is the sum of the two before it, and stops at the first number greater than 4.

Do I have to use every row of a trace table?

No. Exam trace tables are often printed with more rows than you need. Stop when the algorithm stops and leave the rest empty.

How do I trace a flowchart with a loop?

Follow the arrows one box at a time. Every time a box stores a value, write the new value in that variable's column. At a decision, answer the question with the values you have right now, then follow the arrow for that answer.

More from this paper

Every AQA 8525 question we have worked · Guide: Trace tables explained

Learn it step by step

  1. F5.4 Trace tables Algorithms
  2. F5.2 Flowcharts Algorithms
  3. F13.2 Trace tables Exam preparation
Open the lessons

This is our own explanation of a published exam question. It is not written or endorsed by AQA, and the question paper and mark scheme remain AQA's copyright. Read them on AQA's site with the links on this page.