Level:
Correct: 0
Incorrect: 0
Marks: 0/0
Exam Practice
Course:
Topics:
AQA GCSE Computer Science (Paper 1) Smart practice A mixed round aimed at your weak spots
Unit 1
3.1 Fundamentals of algorithms
Unit 2
3.2 Programming
Data types
Data types
Arithmetic operations in a programming language
Arithmetic operations, DIV and MOD
Relational operations in a programming language
Relational operations
Boolean operations in a programming language
Boolean operations in conditions
Data structures
Arrays and records
Input/output
Input and output
String handling operations in a programming language
String handling
Random number generation in a programming language
Random number generation
Structured programming and subroutines (procedures and functions)
Subroutines and structured programming
Avg
score:
–
Topics
done:
0/15

Algorithms: representing, decomposing and tracing

Practise 35 exam-style questions on Algorithms: representing, decomposing and tracing for AQA GCSE Computer Science (Paper 1). Write your answer as you would in the exam and get it marked in seconds against the mark scheme, point by point, with the Study Helper on hand if you get stuck.

  • 35 questions
  • 1–8 marks each
  • Instant marking
  • No sign-up needed
20 questions, marked as you go

Sample questions with model answers

Here are 4 of the questions in this topic, each with a model answer, an explanation of why it earns the marks and the mark scheme an examiner would use.

Question 1

1 mark

The algorithm below gets whole numbers entered by the user.

count ← 0
num ← USERINPUT
WHILE num ≠ 0
  IF num < 0 THEN
    count ← count + 1
  ENDIF
  num ← USERINPUT
ENDWHILE
OUTPUT count

State the purpose of the algorithm.

Model answer

It counts how many negative numbers the user enters before entering 0, and outputs that count.

Explanation

count only goes up when num < 0, and the loop stops when 0 is entered, so the final output is the number of negative values entered. For example, 4, -2, 7, -9, -1 and then 0 outputs 3. Saying 'it counts the numbers' is not enough because positive numbers are not counted.

Mark scheme
  1. 1 mark

    To count (and output) how many negative numbers are entered (before 0 is entered)

    Mark is for AO2 (apply). A. how many numbers less than 0 are entered. NE. counts the numbers entered. R. outputs the negative numbers.

Question 2

2 marks

The algorithm below is written in pseudo-code.

n ← USERINPUT
total ← 0
FOR i ← 1 TO n - 1
  IF n MOD i = 0 THEN
    total ← total + i
  ENDIF
ENDFOR
IF total = n THEN
  OUTPUT True
ELSE
  OUTPUT False
ENDIF

The user types in 28. What is displayed? Describe the purpose of the algorithm.

Model answer

Output: True
Purpose: it checks whether the number entered is equal to the sum of all its factors apart from itself (a perfect number).

Explanation

The factors of 28 that are less than 28 are 1, 2, 4, 7 and 14, and they add up to 28, so True is output. The loop adds every i from 1 to n - 1 that divides n exactly (n MOD i = 0), and the final IF compares that total with n. You do not need to know the name 'perfect number' - describing what the algorithm checks is enough.

Mark scheme
  1. 1 mark

    True

    2 marks for AO2 (apply). I. Case. I. quotation marks.

  2. 1 mark

    To check whether the number entered is equal to the sum of its factors (not including the number itself) // to check whether the number entered is a perfect number

    A. adds up the numbers that divide exactly into n (apart from n) and outputs whether this total is equal to n. NE. 'it adds up the factors' without the comparison with n.

Question 3

3 marks

The algorithm below is meant to output the largest of three whole numbers entered by the user, but it contains a logic error.

01a ← USERINPUT
02b ← USERINPUT
03c ← USERINPUT
04biggest ← a
05IF b > biggest THEN
06  biggest ← b
07ENDIF
08IF c > a THEN
09  biggest ← c
10ENDIF
11OUTPUT biggest

State the output when the user enters 4, then 9, then 7. Give the line number that contains the logic error, and write the corrected line.

Model answer

Output: 7
Line number: 8
Corrected line: IF c > biggest THEN

Explanation

biggest starts as 4 and becomes 9 at line 6, but line 8 compares c with a instead of with biggest; 7 > 4 is true, so biggest is wrongly changed to 7. Comparing c with the largest value found so far fixes it, so the output becomes 9. This is a logic error, not a syntax error: the algorithm runs but gives the wrong result, which is why tracing it with test data finds it.

Mark scheme
  1. 1 mark

    Output: 7

    Mark is for AO2 (apply). R. 9.

  2. 1 mark

    Line number: 8

    2 marks for AO3 (refine).

  3. 1 mark

    Corrected line: IF c > biggest THEN

    A. IF c > a AND c > b THEN. A. ≥ / >= in place of >. A. program code with the same logic. I. Case.

Question 4

4 marks

The algorithm below is written in pseudo-code.

a ← 2
b ← 1
FOR i ← 1 TO 5
  c ← a + b
  a ← b
  b ← c
ENDFOR
OUTPUT b

Fill in the trace table in the figure to show every change to a, b, i and c, and the output. The starting values of a and b are given. There may be more rows than you need; list the values row by row.

Trace table with five columns: a, b, i, c and OUTPUT. Row 1: a = 2, b = 1; i, c and OUTPUT blank. Rows 2 to 9 are empty, for the student to complete.

Model answer

a: 2, 1, 3, 4, 7, 11
b: 1, 3, 4, 7, 11, 18
i: 1, 2, 3, 4, 5
c: 3, 4, 7, 11, 18
OUTPUT: 18

Explanation

In each pass c is the sum of a and b, then a takes the old value of b and b takes the new value c, so each number in the sequence is the sum of the two before it. Five passes give c = 3, 4, 7, 11 and 18, and b is 18 when it is output. The usual error is to update a with c instead of with the old b, which breaks the sequence.

Mark scheme
  1. 1 mark

    i column: 1, 2, 3, 4, 5

    4 marks for AO2 (apply). Values must be in this order. I. Different rows used as long as the order within each column is clear. I. Duplicate values on consecutive rows within a column.

  2. 1 mark

    c column: 3, 4, 7, 11, 18

  3. 1 mark

    a column: 1, 3, 4, 7, 11 and b column: 3, 4, 7, 11, 18 (after the 2 and 1 already given)

    Both columns must be correct for this mark.

  4. 1 mark

    OUTPUT: 18 (once, after the loop)

    R. if more than one value is output.

Ready to try the rest? Every answer you write is marked against the mark scheme, so you can see exactly where the marks are.

Study Helper Hints first, answers after you try

Stuck on this one? Ask for a hint and I’ll point you in the right direction, without giving the answer away. Once you’ve checked your answer, I’ll show you how the marks are awarded.