June 2023 QP - Paper 2 OCR Computer Science GCSE
June 2023 QP - Paper 2 OCR Computer Science GCSE
Do not use:
* 9 9 3 2 5 3 3 4 3 8 *
• a calculator
* J 2 7 7 0 2 *
First name(s)
Last name
INSTRUCTIONS
• Use black ink.
• Write your answer to each question in the space provided. If you need extra space use
the lined pages at the end of this booklet. The question numbers must be clearly shown.
• Answer all the questions.
INFORMATION
• The total mark for this paper is 80.
• The marks for each question are shown in brackets [ ].
• This document has 20 pages.
ADVICE
• Read each question carefully before you start your answer.
2
SECTION A
Tick (3) one box in each row to identify whether each statement describes a low-level
programming language or a high-level programming language.
Write pseudocode to add the integers stored in num1 and num2. Store the result in a
variable with the identifier total
...................................................................................................................................................
.............................................................................................................................................. [1]
(c) Three incomplete pseudocode algorithms are given with a description of the purpose of each
algorithm.
number = 53
if number ……………… 2 == 0 then
print("Even number")
else
print("Odd number")
endif [1]
© OCR 2023
PMT
3
(iii) Finding the difference between two measurements.
measurement1 = 300
measurement2 = 100
01 start = 3
02 do
03 print(start)
04 start = start - 1
05 until start == -1
06 print("Finished")
[3]
© OCR 2023 Turn over
PMT
4
2 This pseudocode algorithm totals all the numbers in the 0-indexed array scores
01 total = 0
02 for scoreCount = 1 to scores.length – 1
03 scores[scoreCount] = total + total
04 next scoreCount
05 print(total)
...................................................................................................................................................
...................................................................................................................................................
[2]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[4]
© OCR 2023
PMT
5
3 An insertion sort is one type of sorting algorithm.
A student has written a pseudocode algorithm to perform an insertion sort on a 1D array names.
(a) Describe the purpose of the variable temp in the insertion sort pseudocode algorithm.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [2]
(b) An insertion sort contains a nested loop; a loop within a loop. In this pseudocode algorithm
the outer loop is a count-controlled loop and the inner loop is a condition-controlled loop.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [2]
6
(c) A bubble sort is another type of sorting algorithm.
(i) Describe one difference between an insertion sort and a bubble sort.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
(ii) Describe two similarities between an insertion sort and a bubble sort.
1 ........................................................................................................................................
...........................................................................................................................................
2 ........................................................................................................................................
...........................................................................................................................................
[2]
© OCR 2023
PMT
7
4 A garden floodlight system uses inputs from sensors and switches to decide whether it should be
turned on.
The table shows the inputs into the system and the meaning of each input value:
The floodlight (Q) is designed to be on (Q = 1) when the switch is turned on and the motion
sensor detects motion at nighttime.
B Q
[3]
8
(b) Identify the logic gates for truth table 1 and truth table 2.
© OCR 2023
PMT
9
5 Charlie is developing an adding game. The rules of the game are:
(a) Charlie has been told that the game will need to be tested before giving it to the players.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
(ii) Complete the table by naming and describing one type of test that should be used on
Charlie's program before releasing it.
[2]
(iii) Complete the table by identifying and describing two features of an IDE that can be
used when testing a program.
Feature Description
[4]
10
(b) Validating inputs can reduce errors when a program is being run.
Identify two methods of validation and explain how they can be used on this game.
Use ...........................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Use ...........................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[6]
© OCR 2023
PMT
11
(c) Write an algorithm to play this game. The rules are repeated from the start of the question
here:
• the player is asked 3 addition questions
• each question asks the player to add together two random whole numbers between 1
and 10 inclusive
• if the player gets the correct answer, 1 is added to their score
• at the end of the game their score is displayed.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [6]
12
SECTION B
Some questions require you to respond using either the OCR Exam Reference Language or a
high-level programming language you have studied. These are clearly shown.
6 OCR Security Services is a company that installs intruder alarm systems in commercial buildings.
The systems use a computer that is connected to the door sensors and window sensors.
© OCR 2023
PMT
13
(a) Below is a table showing some variables within the program.
Tick (3) one box in each row to identify the most appropriate data type for each variable.
(b) The alarm has an algorithm that decides whether to sound the alarm by checking the data
that is stored in the following three variables.
• SystemArmed
• DoorSensorActive
• WindowSensorActive
The alarm will only sound when the alarm has been activated and one or both of the door
and window sensors are activated. When the system needs to sound the alarm it calls the
pre-written procedure SoundAlarm()
Write a program that checks the data in the variables and calls SoundAlarm() when
appropriate.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [4]
14
(c) The alarm system can also have motion sensors. Each type of sensor has a code. The code
for each sensor is given in the table:
Code Sensor
MS Motion sensor
DS Door sensor
WS Window sensor
...................................................................................................................................... [1]
...................................................................................................................................... [1]
(iii) Identify the data type of the data returned by the function CheckSensorCode()
...................................................................................................................................... [1]
...................................................................................................................................... [1]
(v) Identify two programming constructs that have been used in the program.
1 ........................................................................................................................................
2 ........................................................................................................................................
[2]
© OCR 2023
PMT
15
(d) The alarm system has a log that stores a record each time a sensor is triggered. This is
called an event. The record format is given in the table:
Fieldname Description
Date The date the event happened
SensorID The sensor that was activated
SensorType The type of sensor that was activated – Door, Motion or Window
Length The number of seconds the sensor was triggered (to the nearest second)
The log is stored in a database table called events. The current contents of events is
shown:
Write an SQL statement to display the sensor IDs of the door sensors that have been
triggered for more than 20 seconds.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [3]
16
(e) A program written in a high-level language is used to access the data from the database.
This program has a procedure, SaveLogs(), that stores the data to an external text file.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [6]
© OCR 2023
PMT
17
(f) OCR Security Services need to identify the total number of seconds the sensors have been
activated on a specific date.
The data from the database table events is imported into the program written in a high-
level programming language.
The program stores the data in a two-dimensional (2D) string array with the identifier
arrayEvents
(i) An array can only store data of one data type. Any non-string data must be converted to
a string before storing in the array.
...................................................................................................................................... [1]
18
(ii) Write a program that:
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [6]
© OCR 2023
PMT
19
ADDITIONAL ANSWER SPACE
If additional space is required, you should use the following lined page(s). The question number(s)
must be clearly shown in the margin(s).
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
© OCR 2023
PMT
20
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
© OCR 2023