For IndividualsFor Educators
ExpertMinds LogoExpertMinds
ExpertMinds

Ace your certifications with Practice Exams and AI assistance.

  • Browse Exams
  • For Educators
  • Blog
  • Privacy Policy
  • Terms of Service
  • Cookie Policy
  • Support
  • AWS SAA Exam Prep
  • PMI PMP Exam Prep
  • CPA Exam Prep
  • GCP PCA Exam Prep

© 2026 TinyHive Labs. Company number 16262776.

    PracticeAQA GCSEAQA GCSE Computer Science Paper 1 PythonQuestion 05
    Medium3 marksStructured
    Fundamentals of algorithmsGeneraltraceflowchartalgorithms

    AQA GCSE · Question 05 · Fundamentals of algorithms

    start a ← 0 b ← 1 c ← a + b c > 4? yes stop no a ← b b ← c a b c

    Figure 4 shows an algorithm presented as a flowchart. Complete the trace table for the algorithm. You may not need to use all the rows in the table.

    How to approach this question

    Follow the flowchart step-by-step, keeping track of the values of variables a, b, and c. Write down the values in the table each time they change. 1. **Start:** `a` is set to 0, `b` is set to 1. 2. **Loop 1:** * `c ← a + b` → `c = 0 + 1 = 1`. (Record: a=0, b=1, c=1) * `c > 4?` (1 > 4?) is No. * `a ← b` → `a` becomes 1. * `b ← c` → `b` becomes 1. 3. **Loop 2:** * `c ← a + b` → `c = 1 + 1 = 2`. (Record: a=1, b=1, c=2) * `c > 4?` (2 > 4?) is No. * `a ← b` → `a` becomes 1. * `b ← c` → `b` becomes 2. 4. **Loop 3:** * `c ← a + b` → `c = 1 + 2 = 3`. (Record: a=1, b=2, c=3) * `c > 4?` (3 > 4?) is No. * `a ← b` → `a` becomes 2. * `b ← c` → `b` becomes 3. 5. **Loop 4:** * `c ← a + b` → `c = 2 + 3 = 5`. (Record: a=2, b=3, c=5) * `c > 4?` (5 > 4?) is Yes. 6. **Stop:** The algorithm terminates.

    Full Answer

    The completed trace table is: - Row 1: a=0, b=1, c=1 - Row 2: a=1, b=1, c=2 - Row 3: a=1, b=2, c=3 - Row 4: a=2, b=3, c=5
    This algorithm generates the Fibonacci sequence (1, 1, 2, 3, 5, ...) and stops when a number greater than 4 is generated. A trace table helps track the state of variables through each step of the algorithm. - **Initialisation:** `a` = 0, `b` = 1. - **Iteration 1:** - `c` = `a` + `b` = 0 + 1 = 1. - Is `c > 4`? No. - `a` becomes `b` (so `a` = 1). - `b` becomes `c` (so `b` = 1). - *Table state: a=1, b=1, c=1* (The question implies recording the state when c is calculated) - **Iteration 2:** - `c` = `a` + `b` = 1 + 1 = 2. - Is `c > 4`? No. - `a` becomes `b` (so `a` = 1). - `b` becomes `c` (so `b` = 2). - *Table state: a=1, b=2, c=2* - **Iteration 3:** - `c` = `a` + `b` = 1 + 2 = 3. - Is `c > 4`? No. - `a` becomes `b` (so `a` = 2). - `b` becomes `c` (so `b` = 3). - *Table state: a=2, b=3, c=3* - **Iteration 4:** - `c` = `a` + `b` = 2 + 3 = 5. - Is `c > 4`? Yes. - The loop terminates. - *Table state: a=2, b=3, c=5* The trace table should reflect the values of a, b, and c at the point `c` is calculated in each loop iteration.

    Common mistakes

    ✗ Updating `a` and `b` in the wrong order.\n✗ Recording the values in the table at the wrong point in the loop.\n✗ Making an error in the `c > 4` comparison.
    Question 04.2All questionsQuestion 06

    Practice the full AQA GCSE Computer Science Paper 1 Python

    31 questions · hints · full answers · grading

    Sign up freeTake the exam

    More questions from this exam

    Q01.1Figure 1 shows an algorithm, represented using pseudo-code, which assigns a different value to fo...EasyQ01.2The variable `x` is assigned a value using the statement: `x ← LEN(state)` Using Figure 1, what ...EasyQ01.3What is the result of concatenating the contents of the variables `city` and `landmark` in Figure 1?EasyQ01.5The subroutine `POSITION` finds the first position of a character in a string. For example, `POSI...EasyQ02.1Figure 2 shows an algorithm that uses integer division which has been represented using pseudo-co...Easy
    View all 31 questions →