Computer Science (9618) · Oct/Nov 2021 · Question paper 23

Cambridge Computer Science (9618) question paper for paper 23, Oct/Nov 2021 — 9618/23/O/N/21, file 9618_w21_qp_23.pdf.

Advertisement
Loading the paper…
Text of this paper

Cambridge International AS & A Level

* 5 4 2 7 3 9 9 5 0 1 *

COMPUTER SCIENCE
Paper 2 Fundamental Problem-solving and Programming Skills

9618/23
October/November 2021
2 hours

You must answer on the question paper.
You will need:

Insert (enclosed)

INSTRUCTIONS
●
Answer all questions.
●
Use a black or dark blue pen.
●
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.
●
You may use an HB pencil for any diagrams, graphs or rough working.
●
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.
●
The insert contains all the resources referred to in the questions.

This document has 20 pages. Any blank pages are indicated.
DC (CE/CGW) 213696/3
© UCLES 2021

[Turn over

2
Refer to the insert for the list of pseudocode functions and operators.
1

Sylvia is testing a program that has been written by her colleague. Her colleague tells her that the
program does not contain any syntax errors.
(a) (i)

State what her colleague means by “does not contain any syntax errors”.

[1]

(ii)

Identify and describe one other type of error that the program may contain.
Type of error
Description

[2]

(b) Complete the following table by giving the appropriate data type in each case.
Use of variable

Data type

The average mark in a class of 40 students
An email address
The number of students in the class
To indicate whether an email has been read
[4]

© UCLES 2021

9618/23/O/N/21

3
(c) An airline wants to provide passengers with information about individual flights and allow
them to book their flight using an online booking system.
(i)

Tick (3) one box in each row of the table to indicate whether each item of information
would be essential for the customer when making the booking.
Information

Essential

Not essential

Departure time
Flight number
Departure airport
Aircraft type
Ticket price
Number of seats in aircraft
[3]
(ii)

Identify the technique used to filter out information that is not essential when designing
the booking system and state one benefit of this technique.
Technique
Benefit

[2]

(iii)

Identify two additional pieces of essential information that a passenger might need
when booking a flight.
1
2
[2]

© UCLES 2021

9618/23/O/N/21

[Turn over

4
BLANK PAGE

© UCLES 2021

9618/23/O/N/21

5
2

(a) An algorithm to sort a 1D array into ascending order is described as follows:

•
•

move the largest value to the end
keep repeating until the array is sorted.

Apply the process of stepwise refinement to this algorithm in order to produce a more detailed
description.
Write the more detailed description using structured English. Your explanation of the
algorithm should not include pseudocode statements.

[6]

© UCLES 2021

9618/23/O/N/21

[Turn over

6
(b) The program flowchart shown describes a simple algorithm.
START

Set Count to 1

Set Flag to FALSE

Is Flag =
FALSE AND
Count <= 5 ?

YES

NO

ReBoot()

Set Count to Count + 1

Set Flag to Check()

Is Flag =
FALSE ?

YES

NO

Alert(27)

END

© UCLES 2021

9618/23/O/N/21

7
Write pseudocode for the simple algorithm shown on page 6.

[6]

© UCLES 2021

9618/23/O/N/21

[Turn over

8
3

(a) The diagram below represents a queue Abstract Data Type (ADT) that can hold a maximum
of eight items.
The operation of this queue may be summarised as follows:

•
•
•

The front of queue pointer points to the next item to be removed.
The end of queue pointer points to the last item added.
The queue is circular so that empty storage elements can be reused.
0

Frog

1

Cat

2

Fish

3

Elk

Front of queue pointer

End of queue pointer

4
5
6
7
(i)

Describe how “Octopus” is added to the given queue.

[2]

(ii)

Describe how the next item in the given queue is removed and stored in the variable
AnimalName.

[2]

(iii)

Describe the state of the queue when the front of queue and the end of queue pointers
have the same value.

[1]

© UCLES 2021

9618/23/O/N/21

9
(b) Some operations are carried out on the original queue given in part (a).
(i)

The current state of the queue is:
0

Frog

1

Cat

2

Fish

3

Elk

4
5
6
7
Complete the diagram to show the state of the queue after the following operations:
Add “Wasp”, “Bee” and “Mouse”, and then remove two data items.
(ii)

[3]

The state of the queue after other operations are carried out is shown:
0

Frog

1

Cat

2

Fish

3

Elk

4

Wasp

5

Bee

6

Mouse

7

Ant

Front of queue pointer

End of queue pointer

Complete the following diagram to show the state of the queue after the following
operations:
Remove one item, and then add “Dolphin” and “Shark”.
0
1
2
3
4
5
6
7
© UCLES 2021

[2]
9618/23/O/N/21

[Turn over

10
(c) The queue is implemented using a 1D array.
Describe the algorithm that should be used to modify the end of queue pointer when adding
an item to the queue.
Your algorithm should detect any potential error conditions.

[3]

© UCLES 2021

9618/23/O/N/21

11
4

A program controls the heating system in a sports hall.
Part of the program involves reading a value from a sensor. The sensor produces a numeric value
that represents the temperature. The value is an integer, which should be in the range 0 to 40
inclusive.
A program function has been written to validate the values from the sensor.
(a) A test plan is needed to test the function.
Complete the table. The first line has been completed for you.
You can assume that the sensor will generate only integer data values.
Test

Test data value

Explanation

Expected outcome

1

23

Normal data

Data is accepted

2
3
4
5
[4]
(b) A program module controls the heaters. This module operates as follows:

•
•

If the temperature is below 10, switch the heaters on.
If the temperature is above 20, switch the heaters off.

Complete the following state-transition diagram for the heating system:

Start

Heaters
On

Heaters
Off

[3]

© UCLES 2021

9618/23/O/N/21

[Turn over

12
5

The following data items will be recorded each time a student successfully logs on to the school
network:
Data item

Example data

Student ID

"CJL404"

Host ID

"Lib01"

Time and date

"08:30, June 01, 2021"

The Student ID is six characters long. The other two data items are of variable length.
A single string will be formed by concatenating the three data items. A separator character will
need to be inserted between items two and three.
For example:
"CJL404Lib01<separator>08:30, June 01, 2021"
Each string represents one log entry.
A programmer decides to store the concatenated strings in a 1D array LogArray that contains
2000 elements. Unused array elements will contain an empty string.
(a) Suggest a suitable separator character and give a reason for your choice.
Character
Reason

[2]
(b) The choice of data structure was made during one stage of the program development life
cycle.
Identify this stage.
[1]

© UCLES 2021

9618/23/O/N/21

13
(c) A function LogEvents() will:

•
•
•
•

take a Student ID as a parameter
for each element in the array that matches the Student ID parameter:
◦ add the value of the array element to the existing text file LogFile
◦ assign an empty string to the array element
count the number of lines added to the file
return this count.

Write pseudocode for the function LogEvents().

[7]
© UCLES 2021

9618/23/O/N/21

[Turn over

14
6

A mobile phone has a touchscreen. The screen is represented by a grid, divided into 800 rows
and 1280 columns.
The grid is represented by a 2D array Screen of type INTEGER. An array element will be set to 0
unless the user touches that part of the screen.
Many array elements are set to 1 by a single touch of a finger or a stylus.
The following diagram shows a simplified touchscreen. The dark line represents a touch to the
screen. All grid elements that are wholly or partly inside the outline will be set to 1. These elements
are shaded.
The element shaded in black represents the centre point.
11

6

A program is needed to find the coordinates (the row and column) of the centre point. The centre
point on the diagram above is row 6, column 11.
Assume:

•
•

the user may only touch one area at a time
screen rotation does not affect the touchscreen.

The programmer has started to define program modules as follows:
Module

Description

• Called with three parameters of type INTEGER:

SetRow()
(generates test
data)

◦
◦
◦

a row number
the number of pixels to be skipped starting from column 1
the number of pixels that should be set to 1
• Sets the required number of pixels to 1
For example, SetRow(3, 8, 5) will give row 3 as in the diagram shown.

• Takes two parameters of type INTEGER:

SearchInRow()

◦
◦

a row number
a start column (1 or 1280)
• Searches the given row from the start column (either left to right or right to left)
for the first column that contains an element set to 1
• Returns the column number of the first element in the given row that is set to 1
• Returns −1 if no element is set to 1

• Takes two parameters of type INTEGER:
SearchInCol()

© UCLES 2021

◦
◦

a column number
a start row (1 or 800)
• Searches the given column from the start row (either up or down) for the first
row that contains an element set to 1
• Returns the row number of the first element in the given column that is set to 1
• Returns −1 if no element is set to 1
9618/23/O/N/21

15
(a) Write pseudocode to implement the module SetRow().

[5]

© UCLES 2021

9618/23/O/N/21

[Turn over

16
(b) The module description of SearchInRow() is provided here for reference.
Module

Description

• Takes two parameters of type INTEGER:
SearchInRow()

◦
◦

a row number
a start column (1 or 1280)
• Searches the given row from the start column (either left to right or right to left)
for the first column that contains an element set to 1
• Returns the column number of the first element in the given row that is set to 1
• Returns −1 if no element is set to 1

Write pseudocode to implement the module SearchInRow().

© UCLES 2021

9618/23/O/N/21

17

[8]
(c) The following new module is introduced:
Module

GetCentreCol()

Description

• Called with a row number as an INTEGER
• Uses SearchInRow() to find the first and last columns in the given row which
have an array element set to 1

• Returns the index of the column midway between the first and last columns
• Returns −1 if no element is set to 1

Write pseudocode to implement the module GetCentreCol().

[6]
© UCLES 2021

9618/23/O/N/21

18
BLANK PAGE

© UCLES 2021

9618/23/O/N/21

19
BLANK PAGE

© UCLES 2021

9618/23/O/N/21

20
BLANK PAGE

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 the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of
Cambridge Local Examinations Syndicate (UCLES), which itself is a department of the University of Cambridge.

© UCLES 2021

9618/23/O/N/21

Advertisement