968_s21_
968_s21_
CO M P U T E R SCIE N CE 9 6 1 8 /2 2
Paper 2 Fundamental Problem-solving and Programming Skills M ay / J u ne 2 0 2 1
INSERT 2 h ou rs
*3013807674-I*
IN F O R M AT IO N
● This insert contains all the resources referred to in the questions.
● You may annotate this insert and use the blank spaces for planning. D o not w rite y ou r ans w ers on the
insert.
DC (MB) 200598/3
-m
N ote: An error oc c u rs if a f u nc tion c all is not p rop erly f ormed, or if th e p arameters are inc orrec t.
ST R IN G F u nc tions
N U M E R IC F u nc tions
D AT E F u nc tions
O T H E R F u nc tions
Note: This function will generate an ERROR if the file is not already open in READ mode
O P E R AT O R S
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.
m
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
co
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
e.
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.
m
xa
CO M P U T E R SCIE N CE 9 6 1 8 /2 2
Paper 2 Fundamental Problem-solving and Programming Skills M ay / J u ne 2 0 2 1
2 h ou rs
IN ST R U CT IO N S
● Answer all questions
● Use a black or dark blue pen.
● W rite your name, centre number and candidate number in the boxes at the top of the page.
● W rite 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 H B pencil for any diagrams, graphs or rough working.
● Calculators must not be used in this paper.
IN F O R M AT IO N
● The total mark for this paper is 7 5.
● 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.
DC (MB/FC) 200588/5
-m
Refer to the ins ert for the list of pseudocode functions and operators.
1 ( a) ( i) Complete the following table by giving the appropriate data type in each case.
( ii) Evaluate each expression in the following table by using the initial data values shown in
p art ( a) ( i) .
X S2
S1
Ans w er
The number of transitions that result in a different state
The number of transitions with associated outputs
The label that should replace ‘ X ’
The final or halting state
[4 ]
Registered users may borrow books from the library for a period of time.
( i) State th ree items of data that must be stored for each loan.
1 ........................................................................................................................................
2 ........................................................................................................................................
3 ........................................................................................................................................
[ 2]
( ii) State one item of data that will be required in the library system but does not need to be
stored for each loan.
..................................................................................................................................... [ 1]
( iii) One operation that manipulates the data stored for each loan, would produce a list of all
overdue books.
Operation 1 .......................................................................................................................
...........................................................................................................................................
Operation 2 .......................................................................................................................
...........................................................................................................................................
[ 2]
m
co
e.
at
-m
m
xa
A B
Dolphin Cat Fish Elk
............................................................................................................................................. [ 1]
( b) Give the technical term for the item labelled A in the diagram.
............................................................................................................................................. [ 1]
(c ) Give the technical term for the item labelled B in the diagram.
Term ..........................................................................................................................................
Meaning ....................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[ 2]
( d) Complete the diagram to show the ADT after the data has been sorted in alphabetical order.
Dolph in C at F ish E lk
[ 2]
m
co
e.
at
-m
m
xa
4 A teacher uses a paper-based system to store marks for a class test. The teacher requires a
program to assign grades based on these results.
The program will output the grades together with the average mark.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
m
co
.................................................................................................................................................... [ 6 ]
e.
at
-m
m
xa
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [ 6 ]
( ii) The student decides to modify the algorithm so that each element of the array will contain
a unique value.
Describe the changes that the student needs to make to the algorithm.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
m
co
..................................................................................................................................... [ 3]
e.
at
-m
m
xa
Ans w er
...........................................................................................................................................
..................................................................................................................................... [ 2]
m
co
e.
at
-m
m
xa
B LAN K P AG E
m
co
e.
at
-m
m
xa
The string may contain both upper and lower case characters.
Each count value will be stored in a unique element of a global 1D array CharCount of type
INTEGER. The array will contain six elements.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
m
..........................................................................................................................................................
co
e.
at
..........................................................................................................................................................
-m
m
xa
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [ 8]
7 A procedure, FormatName():
• is called with a string containing words and spaces as its parameter. In this context, a word is
any sequence of characters that does not contain a space character.
• creates a new formatted string from this string with the following requirements:
1. Any leading spaces removed (spaces before the first word).
2. Any trailing spaces removed (spaces after the last word).
3. Any multiple spaces between words converted to a single space.
4 . All characters converted to lower case.
The FormatName() procedure has been written in a programming language and is to be tested
using the black-box method.
( a) Give a test string that could be used to show that all f ou r formatting requirements have been
applied correctly.
............................................................................................................................................. [ 3]
( b) The FormatName() procedure should assign a value to the global variable FString.
There is a fault in the program, which means that the assignment does not always take place.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [ 2]
m
co
e.
at
-m
m
xa
8 A program is needed to take a string containing a full name and to produce a new string of initials.
Some words in the full name will be ignored. For example, “ the” , “ and” , “ of” , “ for” and “ to” may all
be ignored.
For example:
F u ll name Initials
Integrated Development Environment IDE
The American Standard Code for Information Interchange ASCII
• a ten element 1D array IgnoreList of type STRING to store the ignored words
• a string FNString to store the full name string.
Assume that:
• each alphabetic character in the full name string may be either upper or lower case
• the full name string contains at least one word.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [ 5]
m
co
e.
at
-m
m
xa
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
m
co
...................................................................................................................................................
e.
at
-m
............................................................................................................................................. [ 8]
m
xa
B LAN K P AG E
m
co
e.
at
-m
m
xa
B LAN K P AG E
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.
m
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
co
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
e.
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.
m
xa