Computer Science (2210) · Oct/Nov 2023 · Question paper 23
Cambridge Computer Science (2210) question paper for paper 23, Oct/Nov 2023 — 2210/23/O/N/23, file 2210_w23_qp_23.pdf.
Text of this paper
www.dynamicpapers.com
Cambridge O Level
* 8 5 7 6 3 6 5 8 6 9 *
COMPUTER SCIENCE
Paper 2 Algorithms, Programming and Logic
2210/23
October/November 2023
1 hour 45 minutes
You must answer on the question paper.
No additional materials are needed.
INSTRUCTIONS
●
Answer all questions.
●
Use a black or dark blue pen. You may use an HB pencil for any diagrams or graphs.
●
Write your name, centre number and candidate number in the boxes at the top of the page.
●
Write your answer to each question in the space provided.
●
Do not use an erasable pen or correction fluid.
●
Do not write on any bar codes.
●
Calculators must not be used in this paper.
INFORMATION
●
The total mark for this paper is 75.
●
The number of marks for each question or part question is shown in brackets [ ].
●
No marks will be awarded for using brand names of software packages or hardware.
This document has 16 pages. Any blank pages are indicated.
DC (CE/CT) 333541
© UCLES 2023
[Turn over
2
1
2
www.dynamicpapers.com
Tick (3) one box to show which term is an example of a verification check.
A
Double entry check
B
Format check
C
Length check
D
Presence check
[1]
Tick (3) one box to show which library routine returns the remainder of a division.
A
DIV
B
MOD
C
RANDOM
D
ROUND
© UCLES 2023
[1]
2210/23/O/N/23
3
3
www.dynamicpapers.com
(a) Four pseudocode descriptions and five pseudocode keywords are shown.
Draw one line to link each pseudocode description to the most appropriate pseudocode
keyword. Not all pseudocode keywords will be used.
Pseudocode description
Pseudocode keyword
stores data in a file
OUTPUT
WRITE
retrieves data from a file
READ
displays data on a screen
OPEN
enters data from a keyboard
INPUT
[4]
(b) Give two reasons for storing data in a file.
1
2
[2]
© UCLES 2023
2210/23/O/N/23
[Turn over
4
4
www.dynamicpapers.com
A programmer is writing a data entry program for booking theatre seats.
The programmer needs the program to accept only whole numbers that are greater than or equal
to one and less than or equal to six.
(a) Give the names of two validation checks that are required for this program.
1
2
[2]
(b) Complete this pseudocode to perform your two validation checks, using your answers given
in (a):
OUTPUT "Please enter the number of seats you want to book "
INPUT Seats
[5]
(c) Give one item of test data to use when testing this program.
State the reason for your choice of test data.
Test data
Reason for choice
[2]
© UCLES 2023
2210/23/O/N/23
5
www.dynamicpapers.com
BLANK PAGE
© UCLES 2023
2210/23/O/N/23
[Turn over
6
5
www.dynamicpapers.com
An algorithm has been written in pseudocode to check if a new password is in a list of previously
used passwords OldList[]
If the password is not found, the new password will be stored at the end of the list to replace
"XXXX" already stored there.
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
OUTPUT "Enter your new password "
INPUT NewPassword
1
Posn
FALSE
Found
REPEAT
IF Password = OldList[Posn]
THEN
TRUE
Found
Posn + 1
ELSE Posn
ENDIF
UNTIL Found AND OldList[Posn] = "XXXX"
IF Found
THEN
OUTPUT "Password has been used before"
ELSE
INPUT "New password accepted"
NewPassword
OldList[Posn]
ENDIF
(a) Identify the three errors in the pseudocode and suggest corrections.
Error 1
Correction
Error 2
Correction
Error 3
Correction
[3]
© UCLES 2023
2210/23/O/N/23
7
www.dynamicpapers.com
(b) Complete this flowchart for the corrected algorithm:
START
STOP
[6]
© UCLES 2023
2210/23/O/N/23
[Turn over
8
6
www.dynamicpapers.com
There are three descriptions of logic gates. Each logic gate has two inputs A and B with one
output X.
Identify each logic gate.
Complete a truth table for each logic gate.
(a) The only time the output is 1 is when both inputs are 1.
Logic gate
Complete the truth table for this description.
A
B
0
0
0
1
1
0
1
1
X
[2]
(b) The output is 1 when both inputs are different.
Logic gate
Complete the truth table for this description.
A
B
0
0
0
1
1
0
1
1
X
[2]
(c) The only time the output is 1 is when both inputs are 0.
Logic gate
Complete the truth table for this description.
A
B
0
0
0
1
1
0
1
1
X
[2]
© UCLES 2023
2210/23/O/N/23
9
www.dynamicpapers.com
(d) Consider this logic expression:
X = (NOT A OR NOT B) OR NOT C
Draw a logic circuit for this logic expression. Each logic gate must have a maximum of two
inputs. Do not attempt to simplify this logic expression.
A
B
X
C
[5]
7
A program uses both local variables and global variables.
Describe two differences between local variables and global variables.
Difference 1
Difference 2
[4]
© UCLES 2023
2210/23/O/N/23
[Turn over
www.dynamicpapers.com
10
8
This is an algorithm to find if a batch of parts has been manufactured successfully.
START
Accept
Reject
0
0
INPUT PartOK
IS PartOK
= 'Y'?
No
Reject
Reject + 1
Yes
Accept
No
Accept + 1
IS Accept
= 10 ?
Yes
IS Reject
> 1?
Yes
No
Reject/Accept * 100
OUTPUT
"Too many rejected ",
Error, "% error"
OUTPUT
"Success"
STOP
© UCLES 2023
Error
2210/23/O/N/23
www.dynamicpapers.com
11
(a) Complete the trace table using this data:
Y, Y, Y, N, Y, Y, Y, Y, N, Y, Y, Y, Y
Accept
Reject
PartOK
Error
OUTPUT
[5]
(b) Describe how the algorithm should be changed to accept ‘Y’ or ‘y’ for a successfully
manufactured part.
[3]
© UCLES 2023
2210/23/O/N/23
[Turn over
12
9
www.dynamicpapers.com
A sanctuary for pheasants has set up a new database table called PheasantList to store details
of the different species of bird at the sanctuary. Part of this table is given, showing: species,
description, number of birds at the sanctuary, if the birds are breeding or not, and number of
young born this year.
Species
Description
NumberBirds
Breeding
Young
Edwards
blue-black with white tail
5
Yes
0
Japanese green
dark green with pale grey tail
2
Yes
2
Reeves
golden, white and red scaled plumage
4
Yes
1
Crawfords Kalij
glossy blue-black plumage
4
No
0
Crested fireback
blue-black with black tail
3
No
0
True silver
white laced top half and black lower half
7
Yes
1
Siamese fireback
grey plumage with crimson legs and feet
5
No
0
Mikado
iridescent plumage with white striped wings
3
Yes
4
Red junglefowl
many colours
2
Yes
0
Himalayan monal
many colours with metallic green crest
3
Yes
2
White eared
white with ear tufts
5
Yes
3
Brown eared
brown with ear tufts
9
Yes
1
Ring necked
long tail with white ring neck
2
Yes
2
Golden
rainbow coloured
3
Yes
4
(a) State the number of records and fields in this part of the database table.
Records
Fields
[2]
(b) (i)
Give the name of a field that could be used for the primary key.
[1]
(ii)
Explain why the sanctuary might decide not to use the field in (b)(i) as the primary key.
[1]
(iii)
A new field SpeciesID is added to the database table.
This field contains a six-character code, for example Ph0001.
Give a reason why this field would be a better primary key.
[1]
© UCLES 2023
2210/23/O/N/23
13
www.dynamicpapers.com
(c) Write the output that would be given by this structured query language (SQL) statement:
SELECT Species, Description
FROM PheasantList
WHERE NumberBirds > 6;
[2]
(d) Complete this SQL statement to display all the species of pheasant where the birds are
breeding and there were no young born this year:
SELECT
FROM
WHERE
;
[4]
© UCLES 2023
2210/23/O/N/23
[Turn over
14
www.dynamicpapers.com
10 A weather station takes temperature readings once an hour for a week. These temperatures are
stored in a two-dimensional (2D) array Temperatures[]
Each column contains 24 readings for a single day. The first temperature is recorded at 00:00 and
the final temperature at 23:00. There are seven columns, one for each day of the week, starting
with Monday and ending with Sunday.
The variables MaxDay, MinDay and AvDay are used to store the maximum, minimum, and
average temperatures for a day. The variables MaxWeek, MinWeek and AvWeek are used to store
the maximum, minimum, and average temperatures for the week.
The array has already been set up and the data stored.
Write a program that meets the following requirements:
•
finds the maximum and minimum temperatures for each day
•
calculates the average temperature for each day
•
outputs for each day:
–
name of the day, for example Monday
–
maximum temperature
–
minimum temperature
–
average temperature
•
finds the maximum and minimum temperatures for the week
•
calculates the average temperature for the week
•
outputs:
–
maximum temperature for the week
–
minimum temperature for the week
–
average temperature for the week.
All temperatures output must be rounded to two decimal places.
You must use pseudocode or program code and add comments to explain how your code works.
All inputs and outputs must contain suitable messages.
You do not need to declare any arrays or variables; you may assume that this has already been
done.
You do not need to initialise the data in the array Temperatures[]
© UCLES 2023
2210/23/O/N/23
15
www.dynamicpapers.com
© UCLES 2023
2210/23/O/N/23
[Turn over
16
www.dynamicpapers.com
[15]
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.
Cambridge Assessment International Education is part of Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.
© UCLES 2023
2210/23/O/N/23