Computer Science (9618) · Oct/Nov 2021 · Question paper 22
Cambridge Computer Science (9618) question paper for paper 22, Oct/Nov 2021 — 9618/22/O/N/21, file 9618_w21_qp_22.pdf.
Text of this paper
Cambridge International AS & A Level
* 9 6 0 1 3 8 7 0 0 9 *
COMPUTER SCIENCE
Paper 2 Fundamental Problem-solving and Programming Skills
9618/22
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 (LK/CGW) 213669/3
© UCLES 2021
[Turn over
2
Refer to the insert for the list of pseudocode functions and operators.
1
(a) A programmer applies decomposition to a problem that she has been asked to solve.
Describe decomposition.
[2]
(b) The following pseudocode assigns a value to an element of an array:
ThisArray[n]
← 42
Complete the following table by writing the answer for each row.
Answer
The number of dimensions of ThisArray
The technical terms for minimum and
maximum values that the variable n may take
The technical term for the variable n in the
pseudocode statement
[3]
(c) Complete the pseudocode expressions so that they evaluate to the values shown.
Any functions and operators used must be defined in the insert.
Expression
Evaluates to
67
('C')
54
2 * ("27")
(27 / )
"Sub" & ("Abstraction" , , )
13
"Subtract"
[4]
© UCLES 2021
9618/22/O/N/21
3
(d) Evaluate the expressions given in the following table. The variables have been assigned
values as follows:
←
←
←
TRUE
PumpOn
TRUE
PressureOK
FALSE
HiFlow
Expression
Evaluates to
PressureOK AND HiFlow
PumpOn OR PressureOK
NOT PumpOn OR (PressureOK AND NOT HiFlow)
NOT (PumpOn OR PressureOK) AND NOT HiFlow
[2]
© UCLES 2021
9618/22/O/N/21
[Turn over
4
2
(a) An algorithm will:
1.
2.
3.
4.
5.
6.
input an integer value
jump to step 6 if the value is zero
sum and count the positive values
sum and count the negative values
repeat from step 1
output the two sum values and the two count values.
Draw a program flowchart on the following page to represent the algorithm.
Note that variable declarations are not required in program flowcharts.
© UCLES 2021
9618/22/O/N/21
5
[5]
© UCLES 2021
9618/22/O/N/21
[Turn over
6
(b) A software company is working on a project to develop a website for a school.
The school principal has some ideas about the appearance of the website but is unclear
about all the details of the solution. The principal would like to see an initial version of the
website.
(i)
Identify a life cycle method that would be appropriate in this case.
Give a reason for your choice.
Life cycle method
Reason
[2]
(ii)
The website project has progressed to the design stage.
State three activities that will take place during the design stage of the program
development life cycle.
1
2
3
[3]
© UCLES 2021
9618/22/O/N/21
7
BLANK PAGE
© UCLES 2021
9618/22/O/N/21
[Turn over
8
3
A programmer is writing a program to help manage clubs in a school.
Data will be stored about each student in the school and each student may join up to three clubs.
The data will be held in a record structure of type Student.
The programmer has started to define the fields that will be needed as shown in the following
table.
Field
Typical value
Comment
StudentID
"CF1234"
Unique to each student
Contains letters, numbers and certain symbols
Club_1
1
Any value in the range 1 to 99 inclusive
Club_2
14
Any value in the range 1 to 99 inclusive
Club_3
27
Any value in the range 1 to 99 inclusive
(a) (i)
Write pseudocode to declare the record structure for type Student.
[3]
(ii)
A 1D array Membership containing 3000 elements will be used to store the student
data.
Write pseudocode to declare the Membership array.
[2]
(iii)
Some of the elements of the array will be unused.
Give an appropriate way of indicating an unused array element.
[1]
(iv)
Some students are members of less than three clubs.
State one way of indicating an unused club field.
[1]
© UCLES 2021
9618/22/O/N/21
9
(b) A procedure GetIDs() will:
•
•
•
prompt and input the number of a club
output the StudentID of all the students who are members of that club
output a count of all students in the given club.
Write pseudocode for the procedure GetIDs().
[7]
© UCLES 2021
9618/22/O/N/21
[Turn over
10
4
The following is a procedure design in pseudocode.
Line numbers are given for reference only.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
PROCEDURE Check(InString : STRING)
DECLARE Odds, Evens, Index : INTEGER
←0
←0
←1
Odds
Evens
Index
WHILE Index <= LENGTH(InString)
IF STR_TO_NUM(MID(InString, Index, 1)) MOD 2 <> 0 THEN
Odds + 1
Odds
ELSE
Evens + 1
Evens
ENDIF
Index + 1
Index
ENDWHILE
←
←
←
CALL Result(Odds, Evens)
ENDPROCEDURE
(a) Complete the following table by giving the answers, using the given pseudocode.
Answer
A line number containing a variable being incremented
The type of loop structure
The number of functions used
The number of parameters passed to STR_TO_NUM()
The name of a procedure other than Check()
[5]
(b) The pseudocode includes several features that make it easier to read and understand.
Identify three of these features.
1
2
3
[3]
© UCLES 2021
9618/22/O/N/21
11
(c) (i)
The loop structure used in the pseudocode is not the most appropriate.
State a more appropriate loop structure and justify your choice.
Loop structure
Justification
[2]
(ii)
The appropriate loop structure is now used. Two lines of pseudocode are changed and
two lines are removed.
Write the line numbers of the two lines that are removed.
[1]
© UCLES 2021
9618/22/O/N/21
[Turn over
12
5
A company has several departments. Each department stores the name, email address and the
status of each employee in that department in its own text file. All text files have the same format.
Employee details are stored as three separate data strings on three consecutive lines of the file.
An example of the first six lines of one of the files is as follows:
File line
Comment
1
First employee name
2
First email address
3
First employee status
4
Second employee name
5
Second email address
6
Second employee status
A procedure MakeNewFile() will:
•
take three parameters as strings:
○ an existing file name
○ a new file name
○ a search status value
•
•
create a new text file using the new file name
write all employee details to the new file where the employee status is not equal to the search
status value
count the number of sets of employee details that were in the original file
count the number of sets of employee details that were written to the new file
produce a summary output.
•
•
•
An example summary output is as follows:
File Marketing contained 54 employee details
52 employee sets of details were written to file NewMarketingList
(a) Write pseudocode for the procedure MakeNewFile().
© UCLES 2021
9618/22/O/N/21
13
[7]
© UCLES 2021
9618/22/O/N/21
[Turn over
14
(b) An alternative format could be used for storing the data.
A text file will still be used.
(i)
Describe the alternative format.
[1]
(ii)
State one advantage and one disadvantage of the alternative format.
Advantage
Disadvantage
[2]
© UCLES 2021
9618/22/O/N/21
15
BLANK PAGE
© UCLES 2021
9618/22/O/N/21
[Turn over
16
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 will 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 on 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 of the touch.
11
6
A program is needed to find the coordinates (the row and column) of the centre point. The centre
point on the diagram shown 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 decided to use global values CentreRow and CentreCol as coordinate
values for the centre point.
The programmer has started to define program modules as follows:
Module
Description
FirstRowSet()
• Searches for the first row that has an array element set to 1
• Returns the index of that row (1 is the first row)
• Returns −1 if there are no elements set to 1
LastRowSet()
• Searches for the last row that has an array element set to 1
• Returns the index of that row
• Returns −1 if there are no elements set to 1
FirstColSet()
• Searches for the first column that has an array element set to 1
• Returns the index of that column (1 is the first column)
• Returns −1 if there are no elements set to 1
LastColSet()
• Searches for the last column that has an array element set to 1
• Returns the index of that column
• Returns −1 if there are no elements set to 1
© UCLES 2021
9618/22/O/N/21
17
(a) Write efficient pseudocode for the module FirstRowSet().
[7]
© UCLES 2021
9618/22/O/N/21
[Turn over
18
(b) Describe a feature of your solution to part (a) that indicates the pseudocode represents an
efficient algorithm.
[2]
(c) The programmer decides to produce a single search module FindSet(), which will be able
to perform each of the individual searches performed by the first four modules in the table.
(i)
Outline the changes needed to convert one of the existing modules into this single
module.
[2]
(ii)
Give one possible advantage and one possible disadvantage of combining the four
searches into a single module.
Advantage
Disadvantage
[2]
© UCLES 2021
9618/22/O/N/21
19
(d) An additional module GetCentre() is defined as follows:
Module
GetCentre()
Description
• Calculates the coordinates of the centre point
• Uses the four modules: FirstRowSet(), LastRowSet(),
FirstColSet(), LastColSet()
• Assigns values to CentreRow and CentreCol
• Sets CentreRow to −1 if no screen touch is detected
Write pseudocode for the module GetCentre().
[6]
© UCLES 2021
9618/22/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/22/O/N/21