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

May/June 2020 · 9608/23/M/J/20

Questions5
Marks75
TypeWritten

Answer on paper, open each mark scheme and give yourself marks, then open the Summary.

0 / 0Answer a question to start your score.
Saved 0
Advertisement
1
9608/23/M/J/20 · Question 1May/June 2020Paper 238 marks
Loading question…
Question text

1
(a) Algorithms are produced during program development.
State when you would produce an algorithm during program development and state its
purpose.
When …
…
Purpose …
…
[2]
(b) Selection is one of the basic constructs used in algorithms.
Explain the term selection.
…
…
…
… [2]
(c) Explain the process of problem decomposition. State one reason it may be used.
Explanation …
…
…
Reason …
…
…
[2]
(d) Name two features provided by a typical Integrated Development Environment (IDE) that
assist in the debugging stage of the program development cycle.
1 …
2 …
[2]

2
9608/23/M/J/20 · Question 2May/June 2020Paper 2313 marks
Loading question…
Question text

2
(a) A structure chart is often produced as part of a modular program design. The chart shows the
relationship between modules and the parameters that are passed between them.
Give two other features the structure chart can show.
Feature 1 …
…
Feature 2 …
…
[2]
(b) The following structure chart shows the relationship between three modules.
ModuleA()
ParW
ParX
ParZ
ModuleB()
ModuleC()
Parameter data types are:
ParW : REAL
ParX : INTEGER
ParZ : STRING
(i)
Write the pseudocode header for module ModuleB().
…
…
… [3]
(ii)
Write the pseudocode header for module ModuleC().
…
…
… [3]
(c) A student is developing an algorithm to count the number of times a given string,
SearchString, appears in a 2D array. The array, Item, consists of 100 elements organised
as 50 rows of 2 columns. SearchString could appear in any row or column.
The array is declared in pseudocode as follows:
DECLARE Item : ARRAY [1:50, 1:2] OF STRING
The structured English description of the algorithm is:
1.
SET Count to 0.
2.
Examine the first row of the array.
3.
IF column 1 element value is equal to SearchString, ADD 1 to Count.
4.
IF column 2 element value is equal to SearchString, ADD 1 to Count.
5.
REPEAT from step 3 for next row, UNTIL row is last row.
6.
OUTPUT a suitable message and Count.
Write pseudocode for the algorithm.
…
…
…
…
…
…
…
…
…

3
9608/23/M/J/20 · Question 3May/June 2020Paper 2310 marks
Loading question…
Question text

3
(a) Study the following pseudocode.
Delta(Plan, Actual)
Error
CASE OF Error
Steer − 10
> 10 : Steer
ZCount + 1
0 : ZCount
Steer + 10
< -10 : Steer
OTHERWISE OUTPUT "Unexpected Error"
ENDCASE
Draw a program flowchart to represent the pseudocode. Variable declarations are not
required in program flowcharts.
[5]
(b) The following pseudocode algorithm has been developed to check whether a string contains
a valid password.
To be a valid password, a string must:
•
be longer than five characters
•
contain at least one numeric digit
•
contain at least one upper case letter
•
contain at least one other character (not a numeric digit or an upper case letter).
10 FUNCTION Check(InString : STRING) RETURNS BOOLEAN
11
12
DECLARE Index : INTEGER
13
DECLARE StrLen : INTEGER
14
DECLARE NumUpper, NumDigit : INTEGER
15
DECLARE NextChar : CHAR
16
DECLARE NumOther : INTEGER
17
0
18
NumUpper
0
19
NumDigit
20
LENGTH(InString)
21
StrLen
22
IF StrLen < 6
23
THEN
24
RETURN FALSE
25
ELSE
1 TO StrLen - 1
26
FOR Index
27
// loop for each character
MID(InString, Index, 1)
28
NextChar
29
IF NextChar >= '0' AND NextChar <= '9'
30
THEN
NumDigit + 1 // count digits
31
NumDigit
32
ELSE
33
IF NextChar >= 'A' AND NextChar <= 'Z'
34
THEN
NumUpper + 1 // count upper case
35
NumUpper
36
ENDIF
37
ENDIF
38
ENDFOR
39
ENDIF
40
StrLen – (NumDigit – NumUpper)
41
NumOther
42
IF NumDigit >= 1 AND NumUpper >= 1 AND NumOther >= 1
43
THEN
44
RETURN TRUE
45
ELSE
46
RETURN FALSE
47
ENDIF
48
49 ENDFUNCTION
The pseudocode does not work under all circumstances.
The function was dry run with the string "1234AP" and the following trace table was
produced. The string is an invalid password, but the pseudocode returned the value
TRUE.
Trace
StrLen
Index
NextChar
NumUpper
NumDigit
NumOther
table row
6
0
0
1
1
'1'
2
1
3
2
'2'
4
2
5
3
'3'
6
3
7
4
'4'
8
4
9
5
'A'
10
1
11
3
12
(i)
The pseudocode algorithm contains two errors.
State how the given trace table indicates the existence of each error.
Error 1 …
…
…
…
Error 2 …
…
…
…
[2]
(ii)
Give the line number of each error in the pseudocode algorithm and write the modified
pseudocode to correct each error.
Line number for error 1 …
Correct pseudocode …
…
Line number for error 2 …
Correct pseudocode …
…

Advertisement
4
9608/23/M/J/20 · Question 4May/June 2020Paper 238 marks
Loading question…
Question text

4
A global 1D array, Contact, of type STRING is used to store a list of names and email addresses.
There are 1000 elements in the array. Each element stores one data item. The format of each
data item is as follows:
<Name>':'<EmailAddress>
Name and EmailAddress are both variable-length strings.
For example:
"Wan Zhu:[email protected]"
A function, Extract(), is part of the program that processes the array. A string data item is
passed to the function as a parameter. The function will return the Name part. Validation is not
necessary.
(a) Write program code for the function Extract().
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
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
… [5]
(b) The original function, Extract(), needs to be modified to separate the name from the email
address. The calling program can then use both of these values.
Write, in pseudocode, the header for the modified subroutine. Explain the changes you have
made.
Subroutine header …

5
9608/23/M/J/20 · Question 5May/June 2020Paper 2336 marks
Loading question…
Question text

5
A company hires out rowing boats on a lake. The company has 20 boats, numbered from 1 to 20.
For safety reasons, the boats have to be serviced (checked and any damage repaired) regularly.
The company is developing a program to help manage the servicing of the boats.
Every time a boat is serviced, details are added at the end of the text file, ServiceLog.txt, as a
single line of information. Each boat is serviced before it is hired out for the first time.
The format of each line is as follows:
<BoatNumber><Date>
BoatNumber and Date are as follows:
•
BoatNumber is a two-digit numeric string in the range "01" to "20"
•
Date is an 8-digit numeric string in the format YYYYMMDD
The programmer has defined the first module as follows:
Module
Description
•
Called with a string parameter representing the BoatNumber
•
GetLastService()
Searches through the file ServiceLog.txt
•
Returns the date of the last service in the form "YYYYMMDD"
(a) Write pseudocode for the module GetLastService().
Refer to the Appendix on page 19 for a list of built-in pseudocode functions and operators.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

Advertisement