Past paper – A Level Computer Science (old syllabus, to 2021) (9608)
Cambridge International AS & A Level · 9608
Computer Science (old syllabus, to 2021) · Paper 23
Oct/Nov 2020 · 9608/23/O/N/20
Answer on paper, open each mark scheme and give yourself marks, then open the Summary.
Question text
1
(a) A programmer uses the process of stepwise refinement to break down a problem.
Explain the purpose of stepwise refinement.
…
…
…
… [2]
(b) Programming languages support different data types. These usually include STRING and
REAL.
Complete the table by giving four other data types and an example data value for each.
Data type
Example data value
[4]
(c) An experienced programmer is working on a program that is written in a language she is not
familiar with.
(i)
State one feature of the program that she should be able to recognise.
…
… [1]
(ii)
State the type of skill that would allow her to recognise this feature.
…
… [1]
(d) Give three methods that may be used to identify and locate errors in a program after it has
been written.
You may include one feature found in a typical Integrated Development Environment (IDE).
1 …
2 …
3 …
[3]
Question text
2
(a) An algorithm is needed to input a list of numbers representing test marks for a class of
30 students.
The algorithm will output the number of students who have a mark greater than 75. It will also
output the average mark for the class.
Document the algorithm using structured English.
…
…
…
…
…
…
…
…
…
…
…
… [8]
(b) Each pseudocode statement in the following table contains an error.
State the error in each case.
Refer to the Appendix on page 16 for the list of built-in functions and operators.
Statement
Error
Code
LEFT(3, "Europe")
MID("ALARM:12:02", 7, 6)
Hour
LENGTH(27.5)
Size
INT(27 / (Count + 3)
Num
"Conditional" AND "Loop"
Result
[5]
(c) Part of a program flowchart is shown.
Set Index to 0
Set Status to FALSE
LOOP
Is
YES
Status = TRUE
?
NO
NO
Is Index > 100
?
Set Status to TopUp()
YES
SetLevel("Super")
Set Index to Index + 1
Write program code to implement the flowchart shown. Variable declarations are not
required.
Programming language …
Program code
…
…
…
…
…
…
…
…
Question text
3
A global 1D array, ProdNum, of type INTEGER contains 5 000 elements and is used to store
product numbers.
A procedure is needed to sort ProdNum into ascending order using a bubble sort algorithm.
Write program code for the procedure BubbleSort().
Visual Basic and Pascal: You should include the declaration statements for variables.
Python: You should show a comment statement for each variable used with its data type.
Programming language …
Program code
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
Question text
4
(a) The following pseudocode includes a procedure that searches for a value in a 1D array and
outputs each position in the array where the value is found.
Refer to the Appendix on page 16 for the list of built-in functions and operators.
DECLARE NameList : ARRAY [1:100] OF STRING
DECLARE SearchString : STRING
PROCEDURE Search()
DECLARE Index : INTEGER
1 TO 100
FOR Index
IF NameList[Index] = SearchString
THEN
OUTPUT "Found at " & NUM_TO_STRING(Index)
ENDIF
ENDFOR
ENDPROCEDURE
The specification of module Search() changes. The pseudocode needs to be amended to
meet a new requirement.
The procedure needs to be implemented as a function, Search(), which will:
•
take the search value as a parameter
•
return an integer which is:
either the index value where the search value is first found
•
or –1 if the search value is not found.
•
Write the pseudocode for the function Search().
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
Question text
5
A hashtag is used on a social media network to make it easier to find messages with a specific
theme or content. A hashtag is a string consisting of a hash character ‘#’ followed by a number of
alphanumeric characters.
A message may contain several hashtag strings. A hashtag may be terminated by a space
character, the start of the next hashtag, or by the end of the message.
For example, the following message contains three hashtags:
"#Alarm34 is the result of #BatteryFailure in the #PowerModule"
The hashtags in this message are "#Alarm34", "#BatteryFailure" and "#PowerModule".
A program is being developed to monitor their use.
The program will include two global arrays each containing 10 000 elements:
•
A 1D array, TagString, of type STRING storing each hashtag in a single element of the
array. All unused array elements contain an empty string ("").
•
A 1D array, TagCount, of type INTEGER storing a count of the number of times each hashtag
is used. The count value in a given element relates to the hashtag value stored in the element
in the TagString array with the corresponding index value.
A developer has started to define the modules. Module GetStart() has already been written.
Module
Description
•
Called with two parameters:
•
a message of type STRING
•
an integer giving the number of the required hashtag;
for example, GetStart(Message, 3) would search
GetStart()
for the third hashtag in the string Message
•
Returns an integer value representing the start position of
the hashtag in the message, or value −1 if that hashtag
does not exist
•
Called with a hashtag of type STRING
•
Copies the hashtag to the next free element of the
TagString array, and sets the corresponding element of
AddHashtag()
the TagCount array to 1
•
Returns FALSE if there are no unused elements in the
TagString array, otherwise returns TRUE
•
Called with a message of type STRING
•
Searches the message for hashtags using GetStart()
CountHashtag()
•
Returns a value representing the number of hashtags in the
message
•
Called with a hashtag of type STRING
•
Increments the value of the appropriate element in the
IncrementHashtag()
TagCount array if the hashtag is found
•
Returns TRUE if the hashtag is found, or FALSE if the
hashtag is not found
(a) Write pseudocode for the module AddHashtag().
…
…
…
…
…
…
…
…
…
…
…
…