OCS33704761-question-paper-computational-thinking-algorithms-and-programming
OCS33704761-question-paper-computational-thinking-algorithms-and-programming
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.
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
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
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
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]
(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
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]
© OCR 2023
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]
Identify two methods of validation and explain how they can be used on this game.
Use ...........................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Use ...........................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[6]
© OCR 2023
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]
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
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]
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
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]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [6]
© OCR 2023
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]
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [6]
© OCR 2023
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
20
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
© OCR 2023