Sie sind auf Seite 1von 493

1

A- Level

Computer Science 9608


2015 to 2017
Past Papers & Mark Schemes

Compiled by: M Mushtaq Hussain


03215275281
2

Cambridge International Examinations


Cambridge International Advanced Level
* 4 6 2 2 0 4 8 3 6 1 *

COMPUTER SCIENCE 9608/32


Paper 3 Advanced Theory May/June 2015
1 hour 30 minutes
Candidates answer on the Question Paper.
No Additional Materials are required.
No calculators allowed.

READ THESE INSTRUCTIONS FIRST

Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.

Answer all questions.


No marks will be awarded for using brand names of software packages or hardware.

At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.

The maximum number of marks is 75.

This document consists of 12 printed pages.

DC (FD) 110069
© UCLES 2015 [Turn over
3
2

1 The following syntax diagrams, for a particular programming language, show the syntax of:

• an assignment statement
• a variable
• a letter
• an operator

Assignment statement
Variable = Variable Operator Variable ;

Variable
Letter Letter Letter

Letter Operator
a +

b –

d ÷

(a) The following assignment statements are invalid.

Give the reason in each case.

(i) a = b + c

Reason ..............................................................................................................................

.......................................................................................................................................[1]

(ii) a = b – 2;

Reason ..............................................................................................................................

.......................................................................................................................................[1]

(iii) a = dd * cce;

Reason ..............................................................................................................................

.......................................................................................................................................[1]

© UCLES 2015 9608/32/M/J/15


4
3

(b) Write the Backus-Naur Form (BNF) for the syntax diagrams shown on the opposite page.

<assignmentstatement> ::=

...................................................................................................................................................

<variable> ::=

...................................................................................................................................................

<letter> ::=

...................................................................................................................................................

<operator> ::=

...............................................................................................................................................[6]

(c) Rewrite the BNF rule for a variable so that it can be any number of letters.

<variable> ::=

...............................................................................................................................................[2]

(d) Programmers working for a software development company use both interpreters and
compilers.

(i) The programmers prefer to debug their programs using an interpreter.

Give one possible reason why.

...........................................................................................................................................

.......................................................................................................................................[1]

(ii) The company sells compiled versions of its programs.

Give a reason why this helps to protect the security of the source code.

...........................................................................................................................................

.......................................................................................................................................[1]

© UCLES 2015 9608/32/M/J/15 [Turn over


5
4

2 The incomplete table below shows descriptions and terms relating to malware.

(a) Complete the table with appropriate descriptions and terms.

Description Term

Unsolicited emails containing advertising material sent to a


A
distribution list. ...........................

A standalone piece of malicious software that can reproduce


B
itself automatically. ...........................

..................................................................................................

..................................................................................................
C .................................................................................................. Pharming

..................................................................................................

..................................................................................................

..................................................................................................

..................................................................................................
D .................................................................................................. Phishing

..................................................................................................

..................................................................................................

[4]

(b) For one of the terms, describe:

• a problem that might arise for a user


• a possible solution to the problem

Choose between the terms:

A / B (circle your choice)

Problem ....................................................................................................................................

...................................................................................................................................................

Solution .....................................................................................................................................

...............................................................................................................................................[2]

© UCLES 2015 9608/32/M/J/15


6
5

(c) Explain the following terms:

Encryption .................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Public key ..................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(d) A user downloads software from the Internet.

(i) State what should be part of the download to provide proof that the software is authentic.

.......................................................................................................................................[1]

(ii) Describe the process for ensuring that the software is both authentic and has not been
altered.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[4]

© UCLES 2015 9608/32/M/J/15 [Turn over


7
6

3 (a) A particular programming language allows the programmer to define their own data types.

ThisDate is an example of a user-defined structured data type.

TYPE ThisDate
DECLARE ThisDay : (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31)
DECLARE ThisMonth : (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug,
Sep, Oct, Nov, Dec)
DECLARE ThisYear : INTEGER
ENDTYPE

A variable of this new type is declared as follows:

DECLARE DateOfBirth : ThisDate

(i) Name the non-composite data type used in the ThisDay and ThisMonth declarations.

.......................................................................................................................................[1]

(ii) Name the data type of ThisDate.

.......................................................................................................................................[1]

(iii) The month value of DateOfBirth needs to be assigned to the variable


MyMonthOfBirth.

Write the required statement.

.......................................................................................................................................[1]

© UCLES 2015 9608/32/M/J/15


8
7

(b) Annual rainfall data from a number of locations are to be processed in a program.

The following data are to be stored:

• location name
• height above sea level (to the nearest metre)
• total rainfall for each month of the year (centimetres to 1 decimal place)

A user-defined, composite data type is needed. The programmer chooses


LocationRainfall as the name of this data type.

A variable of this type can be used to store all the data for one particular location.

(i) Write the definition for the data type LocationRainfall.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[5]

(ii) The programmer decides to store all the data in a file. Initially, data from 27 locations will
be stored. More rainfall locations will be added over time and will never exceed 100.

The programmer has to choose between two types of file organisation. The two types are
serial and sequential.

Give two reasons for choosing serial file organisation.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

© UCLES 2015 9608/32/M/J/15 [Turn over


9
8

4 (a) (i) Complete the truth table for this logic circuit:

A
X

Working space
A B X
0 0
0 1
1 0
1 1
[1]

(ii) Complete the truth table for this logic circuit:

Working space
A B X
0 0
0 1
1 0
1 1
[1]

© UCLES 2015 9608/32/M/J/15


10
9

(b) A student decides to write an equation for X to represent the full behaviour of each logic
circuit.

(i) Write the Boolean expression that will complete the required equation for X for each
circuit:

Circuit 1: X = ......................................................................................................................

Circuit 2: X = ..................................................................................................................[2]

(ii) Write the De Morgan’s Law which is shown by your answers to part (a) and part (b)(i).

.......................................................................................................................................[1]

(c) Write the Boolean algebraic expression corresponding to the following logic circuit:

A
B

...............................................................................................................................................[3]

(d) Using De Morgan’s laws and Boolean algebra, simplify your answer to part (c).

Show all your working.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

© UCLES 2015 9608/32/M/J/15 [Turn over


11
10

5 A gardener grows vegetables in a greenhouse. For the vegetables to grow well, the temperature
needs to always be within a particular range.

The gardener is not sure about the actual temperatures in the greenhouse during the growing
season. The gardener installs some equipment. This records the temperature every hour during
the growing season.

(a) Name the type of system described.

...............................................................................................................................................[1]

(b) Identify three items of hardware that would be needed to acquire and record the temperature
data. Justify your choice for each.

Item 1 ........................................................................................................................................

Justification ...............................................................................................................................

...................................................................................................................................................

Item 2 ........................................................................................................................................

Justification ...............................................................................................................................

...................................................................................................................................................

Item 3 ........................................................................................................................................

Justification ................................................................................................................................

...............................................................................................................................................[6]

(c) The equipment records temperatures in the greenhouse. It does this for seven locations.

Each recording is stored as two successive bytes. The format is shown below:

Greenhouse location Temperature reading

7 6 5 4 3 2 1 0

Byte 1 Byte 2

The location is indicated by the setting of one of the seven bits in byte 1. For example,
location 4 is indicated by setting bit 4.

Bit 0 of byte 1 acts as a flag:

• the initial value is zero


• when the reading has been processed it is set to 1

Byte 2 contains the temperature reading (two’s complement integer).

© UCLES 2015 9608/32/M/J/15


12
11

(i) Interpret the data in byte 1 shown below:

7 6 5 4 3 2 1 0
0 0 1 0 0 0 0 1 0 0 0 1 1 0 0 0

Byte 1 Byte 2

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(ii) The system receives a temperature reading of –5 degrees from sensor 6.

Complete the boxes below to show the two bytes for this recording. The reading has not
yet been processed.

7 6 5 4 3 2 1 0

Byte 1 Byte 2

[2]

(d) (i) The accumulator is loaded with the value of byte 1 from location 106.

Write the assembly language instruction to check whether the reading in byte 2 came
from location 4.

LDD 106 // data loaded from address 106

.......................................................................................................................................[4]

(ii) Write the assembly language instruction to set the flag (bit 0) of the byte contained in the
accumulator to 1.

.......................................................................................................................................[2]

© UCLES 2015 9608/32/M/J/15 [Turn over


13
12

6 (a) Four descriptions and three protocols are shown below.

Draw a line to connect each description to the appropriate protocol.

Description Protocol used

email client downloads an email from an email


HTTP
server

email is transferred from one email server to


POP3
another email server

email client sends email to email server SMTP

browser sends a request for a web page to a


web server

[4]

(b) Downloading a file can use the client-server model. Alternatively, a file can be downloaded
using the BitTorrent protocol.

Name the model used.

...............................................................................................................................................[1]

(c) For the BitTorrent protocol, explain the function of each of the following:

(i) Tracker ...............................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(ii) Seed ..................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(iii) Swarm ...............................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.

© UCLES 2015 9608/32/M/J/15


14

CAMBRIDGE INTERNATIONAL EXAMINATIONS


Cambridge International Advanced Level

MARK SCHEME for the May/June 2015 series

9608 COMPUTER SCIENCE


9608/32 Paper 3 (Written paper), maximum raw mark 75

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of
the examination. It shows the basis on which Examiners were instructed to award marks. It does not
indicate the details of the discussions that took place at an Examiners’ meeting before marking began,
which would have considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner
Report for Teachers.

Cambridge will not enter into discussions about these mark schemes.

Cambridge is publishing the mark schemes for the May/June 2015 series for most
Cambridge IGCSE®, Cambridge International A and AS Level components and some
Cambridge O Level components.

® IGCSE is the registered trademark of Cambridge International Examinations.


15
Page 2 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2015 9608 32

1 (a) (i) ‘;’ missing 1

(ii) ‘2’ is not a variable 1

(iii) ‘e’ is not a valid letter 1

(b) <assignment statement> ::=


<variable> = 2
<variable><operator><variable>;
2

<variable> ::= <letter>|<letter><letter> 1


|<letter><letter><letter>

1
<letter> ::= a|b|c|d

<operator> :: =+|-|*|÷

(c) <letter> | <letter><variable> // <letter> | 2


<variable><letter>

(d) (i) debugging is faster / easier


// can debug incomplete code
// better diagnostics 1

(ii) compiler produces executable version – not readable / no need for source
code 1
// difficult to reverse-engineer

Total: 13

2 (a) • Spam 1
• Worm 1

Pharming
redirect website to fake website // domain name server compromised
// proxy server compromised 1

Phishing 1
through email attempt to obtain somebody’s confidential data / install
malware

(b) Spam
• user’s inbox is filled by large amount of unwanted email 1
• user / email server employs filtering software that can divert / delete 1
spam email or
Worm 1
• could corrupt user’s computer // delete data // consume bandwidth
• run anti-virus software in the background // not connect to the Internet 1
// keep OS up-to-date

© Cambridge International Examinations 2015


16
Page 3 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2015 9608 32

(c) encryption: process of turning plain text into cipher text 1


public key: key widely available that can be used to encrypt message
that only owner of private key can decrypt // can be used to decrypt a
message thereby confirming originator of message 1

(d) (i) digital signature 1

(ii) • software is put through hashing algorithm


• hash total is encrypted with private key (digital signature)
• software + encrypted hash / digital signature are sent Any four
• receiver is in possession of sender’s public key points 1
• the received hash total / digital signature is decrypted with public key mark each
(SH)
• the receiver hashes received software (RH)
• If SH matches RH then software is authentic and has not been altered

Total: 13

3 (a) (i) enumerated 1

(ii) record 1

(iii) MyMonthOfBirth  DateOfBirth.ThisMonth 1

(b) (i) TYPE LocationRainfall 1


DECLARE LocationName : STRING 1
DECLARE LocationHeight : INTEGER 1
DECLARE TotalMonthlyRainfall : ARRAY[1..12] OF REAL 1 +1
ENDTYPE

(ii) • no need to re-sort data every time new data is added 1


• only a small file so searching will require little processing 1
• new records can easily be appended 1

[max 2]

Total: 10

4 (a) (i)
Circuit 1

A B X

0 0 1

0 1 1

1 0 1

1 1 0 1

© Cambridge International Examinations 2015


17
Page 4 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2015 9608 32

(ii)
Circuit 2

A B X

0 0 1

0 1 1

1 0 1

1 1 0 1

(b) (i) • circuit 1: A.B 1


• circuit 2: A + B 1

(ii) A.B ≡ A + B 1

(c) ( A + B).B
Mark as follows:
( A + B) 1
.B 1
bar over whole expression 1

(d) ( A + B).B
1
= ( A + B) + B
1
= ( A + B) + B
1
= A + ( B + B)
= A +1 1
=1 1

allow f.t. from (c) [max 3]

Total: 11

5 (a) Monitoring system 1

(b) • temperature sensor … 1


• transmits measured temperature 1
• analogue to digital converter … 1
• converts analogue signal from sensor to digital value that can be 1
stored 1
• storage device // data logger… 1
• for recording readings from sensor 1
• transmission hardware … 1
1
• to transfer data from sensor to storage device
1
• processor …
• to process incoming data [max 6]

© Cambridge International Examinations 2015


18
Page 5 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2015 9608 32

(c) (i) temperature reading in location 5 1


has been processed 1

(ii) 0100 0000 1111 1011 2


1 mark per byte

(d) (i) AND #B00010000 // AND #&10 // AND #16 1+1+1+


1 mark for AND, 1 mark for address mode, 1 mark for mask, 1 mark for 1
indication of numbering system

(ii) OR #B00000001 // OR #&01 // OR #1 1 +1


1 mark for OR, 1 mark for mask

Total: 17

6 (a)
Description Protocol used

email client downloads an


HTTP 1 mark for
email from an email server
correct
arrow from
each
email is transferred from one email description
POP3
server to another email server

email client sends email to email


SMTP
server

browser sends a request for a web


page to a web server

(b) peer-to-peer 1

(c) (i) Tracker: central server that: 1


stores details of other computers that have all / part of file to be
downloaded
// has data on those peers downloading and uploading file 1
// shares IP addresses with other clients in swarm allowing them to
connect

(ii) Seed: peer computer 1


that has 100% of file // is uploading downloaded content 1

(iii) Swarm: all the connected peer computers 1


that have all or part of the file to be downloaded / uploaded
// share a torrent 1

Total: 11

© Cambridge International Examinations 2015


19

Cambridge International Examinations


Cambridge International Advanced Level
* 4 4 4 9 7 9 0 3 3 7 *

COMPUTER SCIENCE 9608/33


Paper 3 Advanced Theory May/June 2015
1 hour 30 minutes
Candidates answer on the Question Paper.
No Additional Materials are required.
No calculators allowed.

READ THESE INSTRUCTIONS FIRST

Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.

Answer all questions.


No marks will be awarded for using brand names of software packages or hardware.

At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.

The maximum number of marks is 75.

This document consists of 14 printed pages and 2 blank pages.

DC (ST/SW) 95542/2
© UCLES 2015 [Turn over
20
2

1 The following syntax diagrams, for a particular programming language, show the syntax of:

• an assignment statement
• a variable
• a number
• a letter
• a digit
• an operator

Assignment statement
Variable := Variable Operator Number

Variable
Letter Number

Number
Digit

Letter
A

Digit
1

Operator
+

© UCLES 2015 9608/33/M/J/15


21
3

(a) The following assignment statements are invalid.

Give a reason in each case.

(i) A2 = B3 + 123

Reason ..............................................................................................................................

.......................................................................................................................................[1]

(ii) B3 := B3 – 203

Reason ..............................................................................................................................

.......................................................................................................................................[1]

(iii) A2414 := A3 * B

Reason ..............................................................................................................................

.......................................................................................................................................[1]

(b) Complete the Backus-Naur Form (BNF) for the syntax diagrams shown on the opposite page.

<letter> has been done for you.

<assignmentstatement> ::=

...................................................................................................................................................

<variable> ::=

...................................................................................................................................................

<number> ::=

...................................................................................................................................................

<letter> ::= A | B | C

<digit> ::=

...................................................................................................................................................

<operator> ::=

...................................................................................................................................................
[6]

© UCLES 2015 9608/33/M/J/15 [Turn over


22
4

(c) A company develops software. It provides virtual machines for its software developers. The
company has a large number of clients who use a wide range of hardware and software.

(i) Explain the term virtual machine. Ensure that your answer includes the terms hardware
and software.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(ii) Give one benefit to the company of using virtual machines.

...........................................................................................................................................

.......................................................................................................................................[1]

(iii) Give one drawback to the company of using virtual machines.

...........................................................................................................................................

.......................................................................................................................................[1]

© UCLES 2015 9608/33/M/J/15


23
5

2 (a) Four descriptions and three types of local area network (LAN) are shown below.

Draw a line to connect each description to the type of LAN it applies to.

Description Type of LAN

Any packet the listening computer receives Bus with terminators


may be part of a message for itself at each end

Connection provided through an access point Star

A process for handling collisions has to be


Wireless
implemented

Listening computer only receives packets that


are addressed to itself
[4]

(b) A user downloads a file using the FTP protocol.

Explain the function played by each of the following:

(i) Server ................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(ii) Command ..........................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(iii) Anonymous .......................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

© UCLES 2015 9608/33/M/J/15 [Turn over


24
6

3 The incomplete table below shows descriptions and terms relating to malware.

(a) Complete the table with appropriate descriptions and terms.

Description Term

Sending emails which contain a link to a website that


A attempts to trick users into giving confidential personal
data. .....................................

It replicates by inserting itself into another piece of


B .....................................
software.

........................................................................................
C ........................................................................................ Worm

........................................................................................

........................................................................................
D ........................................................................................ Spam

........................................................................................

[4]

(b) Choose term A or term B and describe:

• a problem that might arise for a user


• a possible solution to the problem

Term .....................

Problem ....................................................................................................................................

...................................................................................................................................................

Solution .....................................................................................................................................

...............................................................................................................................................[2]

© UCLES 2015 9608/33/M/J/15


25
7

(c) Explain the following terms:

Cipher text ................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Private key ................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(d) Bill, a manager of a company, sent an email with very sensitive information to a work
colleague, Alison. However, Bill also accidentally sent it to everybody in the company.

Describe the method used that ensured only Alison was able to read the original contents of
the email.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]

© UCLES 2015 9608/33/M/J/15 [Turn over


26
8

4 (a) A particular programming language allows the programmer to define their own data types.

An example of a user-defined data type for an address is:

TYPE ThisAddress
DECLARE ThisHouseNo : INTEGER
DECLARE ThisStreet : STRING
DECLARE ThisTown : STRING
ENDTYPE

A variable of this new type is declared as follows:

DECLARE HomeAddress : ThisAddress

(i) Write the statement that assigns the house number 34 to HomeAddress.

.......................................................................................................................................[1]

(ii) The type definition for ThisAddress is to be changed.

Rewrite one line from the definition for each of the following changes.

House numbers are in the range from 1 to 10.

DECLARE ...........................................................................................................................

The possible towns are limited to: Brightown, Arunde and Shoram.

DECLARE .......................................................................................................................[2]

© UCLES 2015 9608/33/M/J/15


27
9

(b) Temperature data from a number of weather stations are to be processed by a program.

The following data are to be stored:

• weather station ID (a unique four-letter code)

• latitude (to 2 decimal places)

• average temperature (to the nearest whole number) for each year from 2001 to 2015
inclusive

A programmer designs a composite data type WeatherStation. A variable of this type can
be used to store all the data for one particular station.

(i) Write the definition for the user-defined data type WeatherStation.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[5]

(ii) The programmer decides to store all the data in a file. The number of weather stations
could grow to reach 20000, but not all stations will be present at first.

The programmer decides on random organisation for the file.

Describe three steps which show how a new weather station record is added to the file.

1 ........................................................................................................................................

...........................................................................................................................................

2 ........................................................................................................................................

...........................................................................................................................................

3 ........................................................................................................................................

.......................................................................................................................................[3]

© UCLES 2015 9608/33/M/J/15 [Turn over


28
10

5 (a) (i) Complete the truth table for this logic circuit:

A
X

Working space
A B X
0 0
0 1
1 0
1 1
[1]

(ii) Complete the truth table for this logic circuit:

Working space
A B X
0 0
0 1
1 0
1 1
[1]

© UCLES 2015 9608/33/M/J/15


29
11

(b) A student decides to write an equation for X to represent the full behaviour of each logic
circuit.

(i) Write the Boolean expression that will complete the required equation for X for each
circuit:

Circuit 1: X = ......................................................................................................................

Circuit 2: X = ..................................................................................................................[2]

(ii) Write the De Morgan’s Law which is shown by your answers to part (a) and part (b)(i).

.......................................................................................................................................[1]

(c) Write the Boolean algebraic expression corresponding to the following logic circuit:

A
B

...............................................................................................................................................[3]

(d) Using De Morgan’s laws and Boolean algebra, simplify your answer to part (c).

Show all your working.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

© UCLES 2015 9608/33/M/J/15 [Turn over


30
12

6 A company grows vegetables in a number of large greenhouses. For the vegetables to grow well,
the temperature, light level and soil moisture need to always be within certain ranges.

The company installs a computerised system to keep these three growing conditions within the
best ranges. Sensors are used for collecting data about the temperature, light level, and moisture
content of the soil.

(a) Name the type of system described.

...............................................................................................................................................[1]

(b) Give three items of hardware that would be needed for this system. Justify your choice.
Do not include sensors in your answer.

Item 1 ........................................................................................................................................

Justification ...............................................................................................................................

...................................................................................................................................................

Item 2 ........................................................................................................................................

Justification ...............................................................................................................................

...................................................................................................................................................

Item 3 ........................................................................................................................................

Justification ...............................................................................................................................

...............................................................................................................................................[6]

(c) (i) Describe what is meant by feedback in the above system.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

(ii) When the system was designed, various parameters for temperature were set.

Name one of these parameters.

...........................................................................................................................................

.......................................................................................................................................[1]

© UCLES 2015 9608/33/M/J/15


31
13

(iii) Explain how this parameter value is used by the feedback system.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

Question 6 continues on page 14.

© UCLES 2015 9608/33/M/J/15 [Turn over


32
14

Each greenhouse has eight sensors (numbered 1–8).

• The byte at address 150 is used to store eight 1-bit flags.

• A flag is set to indicate whether its associated sensor reading is waiting to be processed.

• More than one sensor reading may be waiting to be processed at any particular moment.

• Data received from the sensors is stored in a block of eight consecutive bytes (addresses
201–208).

• The data from sensor 1 is at address 201, the data from sensor 2 is at address 202, and
so on.

Sensor number
1 2 3 4 5 6 7 8
150 0 1 0 0 0 1 0 1

201 0 0 0 0 0 0 0 0
202 0 0 0 0 0 1 0 0
203 0 0 0 0 0 0 0 0
204 0 0 0 1 0 0 0 0
205 0 0 0 0 0 0 1 0
206 0 0 0 1 0 1 0 0
207 0 0 0 1 0 0 1 0
208 0 0 0 1 0 0 1 0

(d) (i) Interpret the current reading for sensor 2.

...........................................................................................................................................

.......................................................................................................................................[2]

(ii) The accumulator is loaded with the data from location 150.

Write the assembly language instruction to check whether there is a value waiting to be
processed for sensor 6.

LDD 150 // data loaded from address 150

.......................................................................................................................................[3]

© UCLES 2015 9608/33/M/J/15


33

CAMBRIDGE INTERNATIONAL EXAMINATIONS


Cambridge International Advanced Level

MARK SCHEME for the May/June 2015 series

9608 COMPUTER SCIENCE


9608/33 Paper 3 (Written Paper), maximum raw mark 75

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of
the examination. It shows the basis on which Examiners were instructed to award marks. It does not
indicate the details of the discussions that took place at an Examiners’ meeting before marking began,
which would have considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner
Report for Teachers.

Cambridge will not enter into discussions about these mark schemes.

Cambridge is publishing the mark schemes for the May/June 2015 series for most
Cambridge IGCSE®, Cambridge International A and AS Level components and some
Cambridge O Level components.

® IGCSE is the registered trademark of Cambridge International Examinations.


34
Page 2 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2015 9608 33

1 (a) (i) Wrong assignment operator (should be ‘:=’ not ‘=’) 1

(ii) 0 is not a digit 1

(iii) ‘B’ is not a number 1

(b) <assignmentstatement> ::=


<variable> := <variable><operator><number> 1+1
<variable> ::= <letter><number> 1
<number> ::= <digit>| <digit><number> 1+1
<letter> ::= A|B|C 1
<digit> ::= 1|2|3|4|5
<operator> ::= +|-|*|/

(c) (i) Use of software … (idea of using) 1


to implement a hardware set-up (idea of implementing / simulating / 1
emulating)

(ii) e.g.
no need to acquire client hardware for testing /
reduces set-up time for test system /
common development system for all developers 1

(iii) e.g.
software emulation runs slower than real hardware /
not possible to emulate some hardware 1

Total: 13

2 (a)
Description Type of LAN

any packet the listening computer bus with


receives may be part of a message for terminators at
that computer each end
1

connection provided through an access star


point 1

a process for handling collisions has to wireless 1


be implemented

listening computer only receives packets


that are addressed to this computer

1 mark for correct arrow(s) from each description

(b) (i) Server: central computer 1


stores files that are to be downloaded 1

© Cambridge International Examinations 2015


35
Page 3 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2015 9608 33

(ii) Command: user can send action/instruction 1


(or by example, e.g. change directory)
that are carried out on server 1

(iii) Anonymous: allows user to access files 1


user does not need to identify themselves to server 1

Total: 10

3 (a) A Phishing 1
B Virus 1
C a standalone piece of software which can reproduce itself automatically 1
D sending unsolicited emails to a distribution list 1

(b) e.g. phishing


problem: identity fraud / misuse of financial data 1
solution: ignore email / don’t respond to email 1
e.g. virus or
problem: computer may stop working // lost files 1
solution: running anti-virus software 1

(c) cipher text: encrypted text which is not understandable 1


private key: key only known to owner that can be used to encrypt
message to confirm author of message // can be used by owner to decrypt a
message thereby ensuring only owner can read message 1

(d) • Manager encrypts email 1


• using public key of colleague 1
• colleague decrypts email 1
• using his/her private key 1

Total: 12

4 (a) (i) HomeAddress.ThisHouseNo ← 34 1

(ii) DECLARE ThisHouseNo: 1..10 1

DECLARE ThisTown: [Brightown, Arunde, Shoram] 1

(b) (i) TYPE WeatherStation


DECLARE StationID : STRING 1
DECLARE Latitude : REAL 1
DECLARE Temperature : ARRAY[1..15] OF INTEGER 1+1
ENDTYPE 1

(ii) StationID is hashed to produce home location 1


If home location is free insert record 1
Else use overflow method to find free location 1

Total: 11

© Cambridge International Examinations 2015


36
Page 4 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2015 9608 33

5 (a) (i)
Circuit 1

A B X 1

0 0 1

0 1 0

1 0 0

1 1 0

(ii)
Circuit 2

A B X 1

0 0 1

0 1 0

1 0 0

1 1 0

(b) (i) circuit 1 A + B 1


1
circuit 2 A . B

(ii) 1
A+ B ≡ A.B

(c)
( A.B ) + B
mark as :
( A.B ) 1
+B 1
bar over whole expression 1

(d)
( A.B ) + B
1
= ( A.B ) . B
1
= ( A.B ).B
1
= A.( B.B )
= A.0 1
=0 1
max 3
allow f.t. from (c)

Total: 11

© Cambridge International Examinations 2015


37
Page 5 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2015 9608 33

6 (a) Control system 1

(b) Any three different items – max 6 marks

heater / water pump / blinds pump … 1


for altering temperature / watering / light level 1
actuator for… 1
fan for distributing air / water pump / blinds motor 1
analogue to digital converter / digital to analogue convertor … 1
converts analogue signal from sensor to digital value for processing /
converts digital signal to analogue signal for controlling actuator 1
microprocessor … 1
executes control software 1
warning device (speaker/buzzer/light)… 1
to give warning if conditions out of range / hardware malfunction 1
max 6

(c) (i) output of system (alter temperature / light level / soil moisture)
affects input from sensors
continuous 3

(ii) min / max / ideal / mean / extreme temperature // sampling rate // tolerance 1
interval

(iii) reading from sensor is compared with parameter


appropriate action is taken (by example) 2

(d) (i) reading available for processing 1


reading value is 4 1

(ii) AND #B00000100 // AND #&04 // AND #4


1 mark for AND, 1 mark for address mode, 1 mark for mask, 1 mark for
indication of numbering system max 3

Total: 18

© Cambridge International Examinations 2015


38

Cambridge International Examinations


Cambridge International Advanced Level

COMPUTER SCIENCE 9608/43


Paper 4 Further Problem-solving and Programming Skills May/June 2015
PRE-RELEASE MATERIAL
This material should be given to candidates on receipt by the Centre.
* 1 9 1 2 0 8 2 9 4 2 *

READ THESE INSTRUCTIONS FIRST

Candidates should use this material in preparation for the examination. Candidates should attempt the
practical programming tasks using their chosen high-level, procedural programming language.

This document consists of 10 printed pages and 2 blank pages.

DC (AC/SW) 95229/3
© UCLES 2015 [Turn over
39
2

This material is intended to be read by teachers and candidates prior to the June 2015 examination for
9608 Paper 4.

Reminders
The syllabus states:
• there will be questions on the examination paper which do not relate to this pre-release material
• you must choose a high-level programming language from this list:
• Visual Basic (Console Mode)
• Python
• Pascal / Delphi (Console Mode)

The practical skills covered in Paper 2 are a precursor to those required in Paper 4. It is therefore
recommended that the high-level programming language chosen for this paper is the same as that for
Paper 2. This allows for sufficient expertise to be acquired with the opportunity for extensive practice.

Questions on the examination paper may ask the candidate to write:


• structured English
• pseudocode
• program code

A program flowchart should be considered as an alternative to pseudocode for the documenting of an


algorithm design.

Candidates should be confident with:


• the presentation of an algorithm using either a program flowchart or pseudocode
• the production of a program flowchart from given pseudocode (or the reverse)

© UCLES 2015 9608/43/PRE/M/J/15


40
3

TASK 1

A linked list Abstract Data Type (ADT) has these associated operations:

• create linked list


• add item to linked list Key focus: Linked lists
• remove item from linked list

The linked list ADT consists of a linked list of nodes. Each node consists of data and a pointer to the
next node.

TASK 1.1
Consider the use of a linked list to store names in alphabetical order.

The following sequence of operations is carried out:

CreateLinkedList
AddName("Nabila")
AddName("Jack")
AddName("Kerrie") Key focus: Conceptual
AddName("Sara") diagrams of linked lists
RemoveName("Kerrie")
AddName("Zac")

Add appropriate labels to the diagram to show the final state of the linked list. Use the space on the left
as a workspace. Show your final answer in the node shapes on the right:

© UCLES 2015 9608/43/PRE/M/J/15 [Turn over


41
4

TASK 1.2
The linked list is to be implemented as an array of records, where each record represents a node.

The CreateLinkedList operation links all nodes to form the free list and initialises the HeadPointer
and FreePointer.

Complete the diagram to show the values of all pointers after the CreateLinkedList operation has
been carried out.

Key focus: Implementation of


linked lists using an array of records

NameList
HeadPointer Name Pointer
[1]

[2]

[3]

[4]

[5]

FreePointer [6]

[49]

[50]

Write pseudocode for the CreateLinkedList operation.

Write program code from your pseudocode design.

© UCLES 2015 9608/43/PRE/M/J/15


42
5

TASK 1.3
Complete the diagram to show the values of all pointers after the following operations have been
carried out:

AddName("Nabila")
AddName("Jack")
AddName("Kerrie")
AddName("Sara")
RemoveName("Kerrie")
AddName("Zac")
NameList
HeadPointer Name Pointer
[1]

[2]

[3]

[4]

[5]

FreePointer [6]

[49]

[50]

© UCLES 2015 9608/43/PRE/M/J/15 [Turn over


43
6

TASK 1.4
Complete the identifier table for the pseudocode given below.

Identifier Data type Description


Array to store node data
Name to be added
Pointer to next free node in array
Pointer to first node in list
Pointer to current node
Pointer to previous node
Pointer to new node

01 PROCEDURE AddName(NewName)
02 // New name placed in node at head of free list
03 NameList[FreePointer].Name ←
NewName
04 NewNodePointer ←
FreePointer
05 FreePointer ←
NameList[FreePointer].Pointer
06
07 // initialise current pointer to start of list
08 CurrentPointer ←
HeadPointer
09
10 // check that it is not the special case of adding to empty list
11 IF HeadPointer > 0
12 // loop to locate position of new name
13 // saves current pointer and then updates current pointer
14 WHILE NameList[CurrentPointer].Name < NewName
15 PreviousPointer ←
CurrentPointer
16 CurrentPointer ←
NameList[CurrentPointer].Pointer
17 ENDWHILE
18 ENDIF
19
20 // check to see whether new name is first in linked list
21 // if first item then place item at head of list
22 // if not first item then adjust pointers to place it in correct
23 // position in list
24 IF CurrentPointer = HeadPointer
25 THEN
26 NameList[NewNodePointer].Pointer HeadPointer ←
27 HeadPointer ←
NewNodePointer
28 ELSE
29 NameList[NewNodePointer].Pointer ←
NameList[PreviousPointer].Pointer
30 NameList[PreviousPointer].Pointer ←
NewNodePointer
31 ENDIF
32 ENDPROCEDURE

© UCLES 2015 9608/43/PRE/M/J/15


44
7

TASK 1.5
Write program code for the pseudocode given in Task 1.4.

TASK 1.6
The structured English algorithm for the operation to remove a name from the linked list is as follows:

If list is not empty


Find the name to be removed
If it is the first name in the linked list
Adjust the head pointer
If it is not the first name in the linked list
Adjust pointers to exclude the name to be removed from the list
Link released node into free list

TASK 1.6.1
Write the algorithm, as a procedure in pseudocode, from the structured English given above.

TASK 1.6.2
Write program code from your pseudocode design.

TASK 1.6.3
Test your program code for creating a linked list, adding and removing names, using the data given in
Task 1.3.

Suggested extension task


Queues, stacks, binary trees and dictionaries can be implemented as linked lists of nodes.

Design pseudocode and write program code for these data structures.

© UCLES 2015 9608/43/PRE/M/J/15 [Turn over


45
8

TASK 2

A vehicle hire company has cars and trucks for hire.

The unique registration and the engine size (in litres, to the nearest 0.1 of a litre) are stored for all
vehicles.

Data stored about cars also include the hire charge per day (in $) and the number of passengers
allowed.

Data stored about trucks also include the hire charge per hour (in $) and the maximum payload (in kg).

Object-oriented software is to be written to process data about vehicles hired, including calculating the
hire fee.

The superclass (also known as base class or parent class) Vehicle is designed.

Two subclasses (also known as derived classes or child classes) have been identified:

• Car
Key focus: Object-oriented programming
• Truck

TASK 2.1
Complete the inheritance diagram.

© UCLES 2015 9608/43/PRE/M/J/15


46
9

TASK 2.2
Complete the class diagram showing the appropriate properties and methods.

........................................................................

........................................................................

........................................................................

........................................................................

........................................................................

........................................................................

........................................................................

....................................................................... .......................................................................

....................................................................... .......................................................................

....................................................................... .......................................................................

....................................................................... .......................................................................

Constructor() .......................................................................

....................................................................... .......................................................................

....................................................................... .......................................................................

....................................................................... .......................................................................

Note: a constructor is a method that creates a new instance of a class and initialises it.

TASK 2.3
Write program code for the class definitions. Make use of polymorphism and inheritance where
appropriate.

TASK 2.4
Write program code to create a new instance of Car.

Suggested extension task


Write program code to display the properties of the object you created in Task 2.4.

© UCLES 2015 9608/43/PRE/M/J/15 [Turn over


47
10

TASK 3

An intruder detection system is inactive when the power is switched off. The system is activated when
the power is switched on. When the system senses an intruder the alarm bell rings. A reset button is
pressed to turn the alarm bell off and return the system to the active state.

The transition from one state to another is as shown in the state transition table below.

Current state Event Next state


System inactive Switch power on System active
System active Senses intruder Alarm bell rings
System active Switch power off System inactive
Alarm bell rings Press reset button System active
Alarm bell rings Switch power off System inactive

Key focus: State transition diagrams


Complete the diagram.

..............................
start

.............................. ..............................

..............................

..............................

.............................. ..............................

..............................

© UCLES 2015 9608/43/PRE/M/J/15


48

Cambridge International Examinations


Cambridge International Advanced Level

COMPUTER SCIENCE 9608/42


Paper 4 Further Problem-solving and Programming Skills May/June 2015
PRE-RELEASE MATERIAL
This material should be given to candidates on receipt by the Centre.
* 8 3 5 5 5 9 3 5 0 2 *

READ THESE INSTRUCTIONS FIRST

Candidates should use this material in preparation for the examination. Candidates should attempt the
practical programming tasks using their chosen high-level, procedural programming language.

This document consists of 10 printed pages and 2 blank pages.

DC (RW) 107191
© UCLES 2015 [Turn over
49
2

This material is intended to be read by teachers and candidates prior to the June 2015 examination for
9608 Paper 4.

Reminders
The syllabus states:
• there will be questions on the examination paper which do not relate to this pre-release material
• you must choose a high-level programming language from this list:
• Visual Basic (Console Mode)
• Python
• Pascal / Delphi (Console Mode)

The practical skills covered in Paper 2 are a precursor to those required in Paper 4. It is therefore
recommended that the high-level programming language chosen for this paper is the same as that for
Paper 2. This allows for sufficient expertise to be acquired with the opportunity for extensive practice.

Questions on the examination paper may ask the candidate to write:


• structured English
• pseudocode
• program code

A program flowchart should be considered as an alternative to pseudocode for the documenting of an


algorithm design.

Candidates should be confident with:


• the presentation of an algorithm using either a program flowchart or pseudocode
• the production of a program flowchart from given pseudocode (or the reverse)

© UCLES 2015 9608/42/PRE/M/J/15


50
3

TASK 1

A linked list Abstract Data Type (ADT) has these associated operations:

• create linked list


• add item to linked list Key focus: Linked lists
• remove item from linked list

The linked list ADT consists of a linked list of nodes. Each node consists of data and a pointer to the
next node.

TASK 1.1
Consider the use of a linked list to store names in alphabetical order.

The following sequence of operations is carried out:

CreateLinkedList
AddName("Nabila")
AddName("Jack")
AddName("Kerrie") Key focus: Conceptual
AddName("Sara") diagrams of linked lists
RemoveName("Kerrie")
AddName("Zac")

Add appropriate labels to the diagram to show the final state of the linked list. Use the space on the left
as a workspace. Show your final answer in the node shapes on the right:

© UCLES 2015 9608/42/PRE/M/J/15 [Turn over


51
4

TASK 1.2
The linked list is to be implemented as an array of records, where each record represents a node.

The CreateLinkedList operation links all nodes to form the free list and initialises the HeadPointer
and FreePointer.

Complete the diagram to show the values of all pointers after the CreateLinkedList operation has
been carried out.

Key focus: Implementation of


linked lists using an array of records

NameList
HeadPointer Name Pointer
[1]

[2]

[3]

[4]

[5]

FreePointer [6]

[49]

[50]

Write pseudocode for the CreateLinkedList operation.

Write program code from your pseudocode design.

© UCLES 2015 9608/42/PRE/M/J/15


52
5

TASK 1.3
Complete the diagram to show the values of all pointers after the following operations have been
carried out:

AddName("Nabila")
AddName("Jack")
AddName("Kerrie")
AddName("Sara")
RemoveName("Kerrie")
AddName("Zac")
NameList
HeadPointer Name Pointer
[1]

[2]

[3]

[4]

[5]

FreePointer [6]

[49]

[50]

© UCLES 2015 9608/42/PRE/M/J/15 [Turn over


53
6

TASK 1.4
Complete the identifier table for the pseudocode given below.

Identifier Data type Description


Array to store node data
Name to be added
Pointer to next free node in array
Pointer to first node in list
Pointer to current node
Pointer to previous node
Pointer to new node

01 PROCEDURE AddName(NewName)
02 // New name placed in node at head of free list
03 NameList[FreePointer].Name ←
NewName
04 NewNodePointer ←
FreePointer
05 FreePointer ←
NameList[FreePointer].Pointer
06
07 // initialise current pointer to start of list
08 CurrentPointer ←
HeadPointer
09
10 // check that it is not the special case of adding to empty list
11 IF HeadPointer > 0
12 // loop to locate position of new name
13 // saves current pointer and then updates current pointer
14 WHILE NameList[CurrentPointer].Name < NewName
15 PreviousPointer ←
CurrentPointer
16 CurrentPointer ←
NameList[CurrentPointer].Pointer
17 ENDWHILE
18 ENDIF
19
20 // check to see whether new name is first in linked list
21 // if first item then place item at head of list
22 // if not first item then adjust pointers to place it in correct
23 // position in list
24 IF CurrentPointer = HeadPointer
25 THEN
26 NameList[NewNodePointer].Pointer HeadPointer ←
27 HeadPointer ←
NewNodePointer
28 ELSE
29 NameList[NewNodePointer].Pointer ←
NameList[PreviousPointer].Pointer
30 NameList[PreviousPointer].Pointer ←
NewNodePointer
31 ENDIF
32 ENDPROCEDURE

© UCLES 2015 9608/42/PRE/M/J/15


54
7

TASK 1.5
Write program code for the pseudocode given in Task 1.4.

TASK 1.6
The structured English algorithm for the operation to remove a name from the linked list is as follows:

If list is not empty


Find the name to be removed
If it is the first name in the linked list
Adjust the head pointer
If it is not the first name in the linked list
Adjust pointers to exclude the name to be removed from the list
Link released node into free list

TASK 1.6.1
Write the algorithm, as a procedure in pseudocode, from the structured English given above.

TASK 1.6.2
Write program code from your pseudocode design.

TASK 1.6.3
Test your program code for creating a linked list, adding and removing names, using the data given in
Task 1.3.

Suggested extension task


Queues, stacks, binary trees and dictionaries can be implemented as linked lists of nodes.

Design pseudocode and write program code for these data structures.

© UCLES 2015 9608/42/PRE/M/J/15 [Turn over


55
8

TASK 2

A vehicle hire company has cars and trucks for hire.

The unique registration and the engine size (in litres, to the nearest 0.1 of a litre) are stored for all
vehicles.

Data stored about cars also include the hire charge per day (in $) and the number of passengers
allowed.

Data stored about trucks also include the hire charge per hour (in $) and the maximum payload (in kg).

Object-oriented software is to be written to process data about vehicles hired, including calculating the
hire fee.

The superclass (also known as base class or parent class) Vehicle is designed.

Two subclasses (also known as derived classes or child classes) have been identified:

• Car
Key focus: Object-oriented programming
• Truck

TASK 2.1
Complete the inheritance diagram.

© UCLES 2015 9608/42/PRE/M/J/15


56
9

TASK 2.2
Complete the class diagram showing the appropriate properties and methods.

........................................................................

........................................................................

........................................................................

........................................................................

........................................................................

........................................................................

........................................................................

....................................................................... .......................................................................

....................................................................... .......................................................................

....................................................................... .......................................................................

....................................................................... .......................................................................

Constructor() .......................................................................

....................................................................... .......................................................................

....................................................................... .......................................................................

....................................................................... .......................................................................

Note: a constructor is a method that creates a new instance of a class and initialises it.

TASK 2.3
Write program code for the class definitions. Make use of polymorphism and inheritance where
appropriate.

TASK 2.4
Write program code to create a new instance of Car.

Suggested extension task


Write program code to display the properties of the object you created in Task 2.4.

© UCLES 2015 9608/42/PRE/M/J/15 [Turn over


57
10

TASK 3

An intruder detection system is inactive when the power is switched off. The system is activated when
the power is switched on. When the system senses an intruder the alarm bell rings. A reset button is
pressed to turn the alarm bell off and return the system to the active state.

The transition from one state to another is as shown in the state transition table below.

Current state Event Next state


System inactive Switch power on System active
System active Senses intruder Alarm bell rings
System active Switch power off System inactive
Alarm bell rings Press reset button System active
Alarm bell rings Switch power off System inactive

Key focus: State transition diagrams


Complete the diagram.

..............................
start

.............................. ..............................

..............................

..............................

.............................. ..............................

..............................

© UCLES 2015 9608/42/PRE/M/J/15


58

Cambridge International Examinations


Cambridge International Advanced Level
* 0 5 8 4 9 6 7 1 2 6 *

COMPUTER SCIENCE 9608/42


Paper 4 Further Problem-solving and Programming Skills May/June 2015
2 hours
Candidates answer on the Question Paper.
No Additional Materials are required.
No calculators allowed.

READ THESE INSTRUCTIONS FIRST

Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.

Answer all questions.


No marks will be awarded for using brand names of software packages or hardware.

At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.

The maximum number of marks is 75.

This document consists of 16 printed pages.

DC (SLM) 108502
© UCLES 2015 [Turn over
59
2

Throughout the paper you will be asked to write either pseudocode or program code.

Complete the statement to indicate which high-level programming language you will use.

Programming language ...........................................................................................................................

© UCLES 2015 9608/42/M/J/15


60
3

1 A turnstile is a gate which is in a locked state. To open it and pass through, a customer inserts
a coin into a slot on the turnstile. The turnstile then unlocks and allows the customer to push the
turnstile and pass through the gate.

After the customer has passed through, the turnstile locks again. If a customer pushes the turnstile
while it is in the locked state, it will remain locked until another coin is inserted.

The turnstile has two possible states: locked and unlocked. The transition from one state to
another is as shown in the table below.

Current state Event Next state


Locked Insert coin Unlocked
Locked Push Locked
Unlocked Attempt to insert coin Unlocked
Unlocked Pass through Locked

Complete the state transition diagram for the turnstile:

..............................

.............................. ..............................

.............................. ..............................

start ..............................

[5]

© UCLES 2015 9608/42/M/J/15 [Turn over


61
4

2 A declarative programming language is used to represent the knowledge base shown below:

01 capital_city(amman).
02 capital_city(beijing).
03 capital_city(brussels).
04 capital_city(cairo).
05 capital_city(london).
06 city_in_country(amman, jordan).
07 city_in_country(shanghai, china).
08 city_in_country(brussels, belgium).
09 city_in_country(london, uk).
10 city_in_country(manchester, uk).
11 country_in_continent(belgium, europe).
12 country_in_continent(china, asia).
13 country_in_continent(uk, europe).
14 city_visited(amman).
15 city_visited(beijing).
16 city_visited(cairo).

These clauses have the following meaning:

Clause Explanation
01 Amman is a capital city
06 Amman is a city in the country of Jordan
11 Belgium is a country in the continent of Europe
14 The travel writer visited Amman

(a) More facts are to be included.

The travel writer visited the city of Santiago which is the capital city of Chile, in the continent
of South America.

Write additional clauses to record this.

17 ............................................................................................................................................

...................................................................................................................................................

18 ............................................................................................................................................

...................................................................................................................................................

19 ............................................................................................................................................

...................................................................................................................................................

20 ............................................................................................................................................

.............................................................................................................................................. [4]

© UCLES 2015 9608/42/M/J/15


62
5

(b) Using the variable ThisCountry, the goal

country_in_continent(ThisCountry, europe)

returns

ThisCountry = belgium, uk

Write the result returned by the goal:

city_in_country(ThisCity, uk)

ThisCity = ...........................................................................................................................

.............................................................................................................................................. [2]

(c) Complete the rule below to list the countries the travel writer has visited.

countries_visited(ThisCountry)

IF .............................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [4]

© UCLES 2015 9608/42/M/J/15 [Turn over


63
6

3 A shop gives some customers a discount on goods totalling more than $20.
The discounts are:
• 5% for goods totalling more than $100
• 5% with a discount card
• 10% with a discount card and goods totalling more than $100

(a) Complete the decision table.

goods totalling
Y Y Y Y N N N N
more than $20
Conditions

goods totalling
Y Y N N Y Y N N
more than $100

have discount card Y N Y N Y N Y N

No discount
Actions

5% discount

10% discount

[4]

(b) Simplify your solution by removing redundancies.

goods totalling
more than $20
Conditions

goods totalling
more than $100

have discount card

No discount
Actions

5% discount

10% discount

[5]

© UCLES 2015 9608/42/M/J/15


64
7

(c) The simplified table produced in part (b) is used as a design for program code.

The following identifier table shows the parameters to be passed to the function Discount.
This function returns the discount amount as an integer.

Identifier Data type


GoodsTotal INTEGER
HasDiscountCard BOOLEAN

Write program code for this function.

Programming language .............................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [6]

© UCLES 2015 9608/42/M/J/15 [Turn over


65
8

4 A payroll program is to be written using an object-oriented programming language. An Employee


class is designed. Two subclasses have been identified:
• HourlyPaidEmployee who is paid a monthly wage calculated from their hourly rate of pay
and the number of hours worked during the month
• SalariedEmployee who is paid a monthly wage which is one 12th of their annual salary

(a) Draw an inheritance diagram for these classes.

[3]

(b) The design for the Employee class consists of:


• properties
• EmployeeName
• EmployeeID
• AmountPaidThisMonth

• methods
• SetEmployeeName
• SetEmployeeID
• CalculatePay

Write program code for the class definition of the superclass Employee.

Programming language .............................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [5]
© UCLES 2015 9608/42/M/J/15
66
9

(c) (i) State the properties and/or methods required for the subclass HourlyPaidEmployee.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [4]

(ii) State the properties and/or methods required for the subclass SalariedEmployee.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [2]

(d) Name the feature of object-oriented program design that allows the method CalculatePay
to be declared in the superclass Employee.

...................................................................................................................................................

.............................................................................................................................................. [1]

© UCLES 2015 9608/42/M/J/15 [Turn over


67
10

5 Data is stored in the array NameList[1:10]. This data is to be sorted.

(a) (i) Complete the pseudocode algorithm for an insertion sort.

FOR ThisPointer ← 2 TO .................................................


// use a temporary variable to store item which is to
// be inserted into its correct location
Temp ← NameList[ThisPointer]
Pointer ← ThisPointer – 1

WHILE (NameList[Pointer] > Temp) AND .................................................


// move list item to next location
NameList[....................................] ← NameList[....................................]
Pointer ← .................................................
ENDWHILE

// insert value of Temp in correct location


NameList[....................................] ← .................................................
ENDFOR
[7]

(ii) A special case is when NameList is already in order. The algorithm in part (a)(i) is
applied to this special case.

Explain how many iterations are carried out for each of the loops.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [3]

© UCLES 2015 9608/42/M/J/15


68
11

(b) An alternative sort algorithm is a bubble sort:

FOR ThisPointer ← 1 TO 9
FOR Pointer ← 1 TO 9
IF NameList[Pointer] > NameList[Pointer + 1]
THEN
Temp ← NameList[Pointer]
NameList[Pointer] ← NameList[Pointer + 1]
NameList[Pointer + 1] ← Temp
ENDIF
ENDFOR
ENDFOR

(i) As in part (a)(ii), a special case is when NameList is already in order. The algorithm in
part (b) is applied to this special case.

Explain how many iterations are carried out for each of the loops.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [2]

© UCLES 2015 9608/42/M/J/15 [Turn over


69
12

(ii) Rewrite the algorithm in part (b), using pseudocode, to reduce the number of
unnecessary comparisons. Use the same variable names where appropriate.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [5]

© UCLES 2015 9608/42/M/J/15


70
13

6 A queue Abstract Data Type (ADT) has these associated operations:

• create queue
• add item to queue
• remove item from queue

The queue ADT is to be implemented as a linked list of nodes.

Each node consists of data and a pointer to the next node.

(a) The following operations are carried out:

CreateQueue
AddName("Ali")
AddName("Jack")
AddName("Ben")
AddName("Ahmed")
RemoveName
AddName("Jatinder")
RemoveName

Add appropriate labels to the diagram to show the final state of the queue. Use the space on
the left as a workspace. Show your final answer in the node shapes on the right:

[3]

© UCLES 2015 9608/42/M/J/15 [Turn over


71
14

(b) Using pseudocode, a record type, Node, is declared as follows:

TYPE Node
DECLARE Name : STRING
DECLARE Pointer : INTEGER
ENDTYPE

The statement

DECLARE Queue : ARRAY[1:10] OF Node

reserves space for 10 nodes in array Queue.

(i) The CreateQueue operation links all nodes and initialises the three pointers that need
to be used: HeadPointer, TailPointer and FreePointer.

Complete the diagram to show the value of all pointers after CreateQueue has been
executed.

Queue
HeadPointer Name Pointer
[1]

[2]

TailPointer [3]

[4]

[5]

FreePointer [6]

[7]

[8]

[9]

[10]
[4]

© UCLES 2015 9608/42/M/J/15


72
15

(ii) The algorithm for adding a name to the queue is written, using pseudocode, as a
procedure with the header:

PROCEDURE AddName(NewName)

where NewName is the new name to be added to the queue.

The procedure uses the variables as shown in the identifier table.

Identifier Data type Description


Queue Array[1:10] OF Node Array to store node data
NewName STRING Name to be added
FreePointer INTEGER Pointer to next free node in array
HeadPointer INTEGER Pointer to first node in queue
TailPointer INTEGER Pointer to last node in queue
CurrentPointer INTEGER Pointer to current node

PROCEDURE AddName(BYVALUE NewName : STRING)


// Report error if no free nodes remaining
IF FreePointer = 0
THEN
Report Error
ELSE
// new name placed in node at head of free list
CurrentPointer ← FreePointer
Queue[CurrentPointer].Name ← NewName
// adjust free pointer
FreePointer ← Queue[CurrentPointer].Pointer
// if first name in queue then adjust head pointer
IF HeadPointer = 0
THEN
HeadPointer ← CurrentPointer
ENDIF
// current node is new end of queue
Queue[CurrentPointer].Pointer ← 0
TailPointer ← CurrentPointer
ENDIF
ENDPROCEDURE

© UCLES 2015 9608/42/M/J/15 [Turn over


73
16

Complete the pseudocode for the procedure RemoveName. Use the variables listed in
the identifier table.

PROCEDURE RemoveName()
// Report error if Queue is empty
...........................................................................................................................
...........................................................................................................................
...........................................................................................................................
...........................................................................................................................
OUTPUT Queue[…………………………………………………………].Name
// current node is head of queue
...........................................................................................................................
// update head pointer
...........................................................................................................................
// if only one element in queue then update tail pointer
...........................................................................................................................
...........................................................................................................................
...........................................................................................................................
...........................................................................................................................
// link released node to free list
...........................................................................................................................
...........................................................................................................................
...........................................................................................................................
ENDPROCEDURE
[6]

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 International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.

Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.

© UCLES 2015 9608/42/M/J/15


74

CAMBRIDGE INTERNATIONAL EXAMINATIONS


Cambridge International Advanced Level

MARK SCHEME for the May/June 2015 series

9608 COMPUTER SCIENCE


9608/42 Paper 4 (Written Paper), maximum raw mark 75

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of
the examination. It shows the basis on which Examiners were instructed to award marks. It does not
indicate the details of the discussions that took place at an Examiners’ meeting before marking began,
which would have considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner
Report for Teachers.

Cambridge will not enter into discussions about these mark schemes.

Cambridge is publishing the mark schemes for the May/June 2015 series for most
Cambridge IGCSE®, Cambridge International A and AS Level components and some
Cambridge O Level components.

® IGCSE is the registered trademark of Cambridge International Examinations.


75
Page 2 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2015 9608 42

Insert coin

locked unlocked

Attempt to
push insert coin

Pass through
start

Mark as follows:
1 mark for both states correct
1 mark for each further label [5]

2 (a) capital_city(santiago).
city_in_country(santiago, chile).
country_in_continent(chile,south_america).
city_visited(santiago).

accept in any order [4]

(b) ThisCity =
manchester
london [2]

(c) countries_visited(ThisCountry)
IF
city_visited(ThisCity) 1
AND 1
city_in_country(ThisCity, ThisCountry) 2 [4]

© Cambridge International Examinations 2015


76
Page 3 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2015 9608 42

3 (a)

goods totalling
Y Y Y Y N N N N
more than $20
Conditions

goods totalling
Y Y N N Y Y N N
more than $100

have discount card Y N Y N Y N Y N

No discount X X X X X
Actions

5% discount X X

10% discount X

1 1 1
1 mark
mark mark mark
[4]

(b)

goods totalling
Y Y Y Y N
more than $20
Conditions

goods totalling
Y Y N N -
more than $100

have discount card Y N Y N -

No discount X X
Actions

5% discount X X

10% discount X

1 mark per column [5]

© Cambridge International Examinations 2015


77
Page 4 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2015 9608 42

(c) Example Pascal

FUNCTION Discount(GoodsTotal: INTEGER; HasDiscountCard: BOOLEAN) :


INTEGER;

BEGIN
(1) IF GoodsTotal > 20
(1) THEN
(2) IF GoodsTotal > 100
(2) THEN
(3) IF HasDiscountCard = TRUE
(3) THEN
(3) Discount := 10
(3) ELSE
(3) Discount := 5
(2) ELSE
(4) IF HasDiscountCard = TRUE
(4) THEN
(4) Discount := 5
(4) ELSE
(4) Discount := 0
(1) ELSE
(1) Discount := 0;
END;

Example Python

def Discount(GoodsTotal, HasDiscountCard) :

(1) if GoodsTotal > 20:


(2) if GoodsTotal > 100:
(3) if HasDiscountCard == True:
(3) return 10
(3) else:
(3) return 5
(2) else:
(4) if HasDiscountCard == TRUE:
(4) return 5
(4) else:
(4) return 0
(1) else:
(1) return 0 [6]

© Cambridge International Examinations 2015


78
Page 5 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2015 9608 42

4 (a)

[3]

© Cambridge International Examinations 2015


79
Page 6 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2015 9608 42

(b) Example Pascal


Type
Employee = CLASS
PUBLIC
procedure SetEmployeeName
Procedure SetEmployeeID
Procedure CalculatePay
PRIVATE
EmployeeName : STRING
EmployeeID : STRING
AmountPaidThisMonth : Currency
END;

Mark as follows:
Class header (1 mark)
PUBLIC and PRIVATE used correctly (1 mark)
EmployeeName + EmployeeID (1 mark)
AmountPaidThisMonth (1 mark)
Methods x 3 (1 mark)

Example VB

Class Employee
Private EmployeeName As String
Private EmployeeID As String
Private AmountPaidThisMonth As Decimal
Public Sub SetEmployeeName()
End Sub
Public Sub SetEmployeeID()
End Sub
Public Sub CalculatePay()
End Sub

Example Python

Class Employee():
def __init__(self):
self.__EmployeeName = ""
self.__EmployeeID = ""
self.__AmountPaidThisMonth = 0
def SetEmployeeName(self, Name):
self.__EmployeeName = Name
def SetEmployeeID(self, ID):
self.__EmployeeID = ID
def SetAmountPaidThisMonth(self, Paid):
self.__AmountPaidThisMonth = Paid [max 5]

© Cambridge International Examinations 2015


80
Page 7 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2015 9608 42

(c) (i) HoursWorked 1


HourlyPayRate 1
SetHoursWorked 1
CalculatePay : Override 1+1
SetPayRate 1 [max 4]

(ii) AnnualSalary 1
SetSalary 1
CalculatePay : Override 1 [max 2]

(d) Polymorphism [1]

5 (a) (i) FOR ThisPointer  2 TO 10


// use a temporary variable to store item which is to
// be inserted into its correct location
Temp  NameList[ThisPointer]
Pointer  ThisPointer – 1

WHILE (NameList[Pointer] > Temp) AND (Pointer > 0)


// move list item to next location
NameList[Pointer + 1]  NameList[Pointer]
Pointer  Pointer - 1
ENDWHILE

// insert value of Temp in correct location


NameList[Pointer + 1] Temp
ENDFOR
1 mark for each gap filled correctly [7]

(ii) The outer loop (FOR loop) is executed 9 times (1 mark)


it is not dependant on the dataset (1 mark)

The Inner loop (WHILE loop) is not entered (1 mark)


as the condition is already false at the first encounter (1 mark) [max 3]

(b) (i) outer loop is executed 9 times (1 mark)


inner loop is executed 9 times (for each iteration of the outer loop) (1 mark)
not dependant on the dataset (1 mark) [max 2]

© Cambridge International Examinations 2015


81
Page 8 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2015 9608 42

(ii) NumberOfItems  10
REPEAT
NoMoreSwaps  TRUE

FOR Pointer  1 TO NumberOfItems – 1


IF NameList[Pointer] > NameList[Pointer + 1]
THEN
NoMoreSwaps  FALSE
Temp  NameList[Pointer]
NameList[Pointer]  NameList[Pointer + 1]
NameList[Pointer + 1]  Temp
ENDIF
ENDFOR
NumberOfItems  NumberOfItems - 1
UNTIL NoMoreSwaps = TRUE

Mark as follows:
• change outer loop to a REPEAT/WHILE loop (1 mark)
• FOR loop has variable used for final value (1 mark)
• Initialise Boolean variable to TRUE (1 mark)
• set Boolean variable to FALSE in correct place (1 mark)
• number of items to consider on each pass decrements (1 mark)
• Correct stopping condition for REPEAT loop (1 mark) [max 5]

6 (a)

Head Ben

Ahmed

Tail Jatinder 0

1 mark for Head and Tail pointers


1 mark for 3 correct items – linked as shown
1 mark for correct order with null pointer in last nod [3]

© Cambridge International Examinations 2015


82
Page 9 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2015 9608 42

(b) (i)
Queue

HeadPointer Name Pointer

0 [1] 2

[2] 3

TailPointer [3] 4

0 [4] 5

[5] 6

FreePointer [6] 7

1 [7] 8

[8] 9

[9] 10

[10] 0

Mark as follows:

HeadPointer =0 & TailPointer = 0


FreePointer assigned a value
Pointers[1] to [9] links the nodes together
Pointer[10] = 'Null' [4]

(ii) PROCEDURE RemoveName()


// Report error if Queue is empty
IF HeadPointer = 0
THEN
Error
ELSE
OUTPUT Queue[HeadPointer].Name
// current node is head of queue
CurrentPointer  HeadPointer
// update head pointer
HeadPointer  Queue[CurrentPointer].Pointer
//if only one element in queue,then update tail pointer
IF HeadPointer = 0
THEN
TailPointer  0
ENDIF
// link released node to free list
Queue[CurrentPointer].Pointer  FreePointer
FreePointer  CurrentPointer
ENDIF
ENDPROCEDURE [max 6]

© Cambridge International Examinations 2015


83

Cambridge International Examinations


Cambridge International Advanced Level
* 7 8 8 1 0 7 0 8 9 7 *

COMPUTER SCIENCE 9608/43


Paper 4 Further Problem-solving and Programming Skills May/June 2015
2 hours
Candidates answer on the Question Paper.
No Additional Materials are required.
No calculators allowed.

READ THESE INSTRUCTIONS FIRST

Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.

Answer all questions.


No marks will be awarded for using brand names of software packages or hardware.

At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.

The maximum number of marks is 75.

This document consists of 15 printed pages and 1 blank page.

DC (AC/SW) 95230/2
© UCLES 2015 [Turn over
84
2

Throughout the paper you will be asked to write either pseudocode or program code.

Complete the statement to indicate which high-level programming language you will use.

Programming language ...........................................................................................................................

© UCLES 2015 9608/43/M/J/15


85
3

1 A petrol filling station has a single self-service petrol pump.

A customer can use the petrol pump when it is ready to dispense petrol.
The pump is in use when the customer takes the nozzle from a holster on the pump.
The pump dispenses petrol while the customer presses the trigger on the nozzle.
When the customer replaces the nozzle into the holster, the pump is out of use.
The cashier must press a reset button to make the pump ready for the next customer to use.

The petrol pump’s four possible states and the transition from one state to another are as shown in
the table below.

Current state Event Next state

Pump ready Take nozzle Pump in use

Pump in use Press trigger Pump dispensing

Pump dispensing Stop pressing trigger Pump in use

Pump in use Replace nozzle Pump out of use

Pump out of use Reset pump display Pump ready

Complete the state transition diagram for the petrol pump:

...........................

start

........................... ...........................

...........................
...........................

........................... ...........................

........................... ...........................

[9]

© UCLES 2015 9608/43/M/J/15 [Turn over


86
4

2 A declarative programming language is used to represent the knowledge base shown below:

01 dairy_product(cheese).
02 meat(beef).
03 meat(chicken).
04 meat(lamb).
05 made_with(burger, beef).
06 made_with(kofta, lamb).
07 made_with(quiche, cheese).
08 made_with(quiche, egg).
09 made_with(quiche, flour).

These clauses have the following meaning:

Clause Explanation
01 Cheese is a dairy product
02 Beef is a meat
05 A burger is made with beef

(a) More facts are to be included.

Laasi is made with the dairy products milk and yogurt.

Write additional clauses to record this.

10 ..............................................................................................................................................

...................................................................................................................................................

11 ..............................................................................................................................................

...................................................................................................................................................

12 ..............................................................................................................................................

...................................................................................................................................................

13 ..............................................................................................................................................

.............................................................................................................................................. [4]

© UCLES 2015 9608/43/M/J/15


87
5

(b) Using the variable TypeOfMeat, the goal

meat(TypeOfMeat)

returns

TypeOfMeat = beef, chicken, lamb

Write the result returned by the goal:

made_with(quiche, Ingredient)

Ingredient = .........................................................................................................................

.............................................................................................................................................. [2]

(c) Complete the rule to list the dishes made with meat.

contains_meat(Dish)

IF .............................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [4]

© UCLES 2015 9608/43/M/J/15 [Turn over


88
6

3 An insurance company calculates the cost of car insurance from a basic price.

The driver may:


• get a discount on the basic price of the insurance
• have to pay an extra charge

The decision is arrived at as follows:


• for a driver aged 25 or over:
• 5% discount if no previous accident
• no discount if a previous accident
• for a driver under the age of 25:
• 5% discount if no previous accident and licence held for 3 or more years
• no discount if a previous accident but licence held for 3 or more years
• no discount if no previous accident but licence held for less than 3 years
• 10% extra charge if a previous accident and licence held for less than 3 years

(a) Complete the decision table.

Age under 25 Y Y Y Y N N N N
Conditions

Previous accident Y Y N N Y Y N N

Licence held for 3 or


Y N Y N Y N Y N
more years

10% extra charge


Actions

No discount

5% discount

[6]

(b) Simplify your solution by removing redundancies.

Age under 25
Conditions

Previous accident

Licence held for 3 or


more years

10% extra charge


Actions

No discount

5% discount

[3]

© UCLES 2015 9608/43/M/J/15


89
7

(c) The simplified table produced in part (b) is used as a design for program code.

The following identifier table shows the parameters to be passed to the function
CostPercentageChange. This function returns the percentage change from the basic price
as an integer. A discount should be shown as a negative integer. An extra charge should be
shown as a positive integer.

Identifier Data type Comment


DriverAge INTEGER Age of driver in years
HadAccident BOOLEAN Whether driver has had a previous accident
YearsLicenceHeld INTEGER Number of years the driver has held licence

Write program code for this function.

Programming language ............................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [6]

© UCLES 2015 9608/43/M/J/15 [Turn over


90
8

4 A sports club stores data about its members. A program is to be written using an object-oriented
programming language.

A Member class is designed. Two subclasses have been identified:


• FullMember
• JuniorMember

(a) Draw an inheritance diagram for these classes.

[3]

(b) The design for the Member class consists of

• properties
• MemberName
• MemberID
• SubscriptionPaid

• methods
• SetMemberName
• SetMemberID
• SetSubscriptionPaid

© UCLES 2015 9608/43/M/J/15


91
9

Write program code for the class definition of the superclass Member.

Programming language ....................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..................................................................................................................................................... [5]

(c) Additionally a DateOfBirth property is required for the JuniorMember class.

(i) Write program code for the class definition for the subclass JuniorMember.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [3]

(ii) Write program code to create a new instance of JuniorMember. Use identifier
NewMember with the following data:
name Ahmed with member ID 12347, born on 12/11/2001, who has paid his subscription.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [3]

© UCLES 2015 9608/43/M/J/15 [Turn over


92
10

5 A stack Abstract Data Type (ADT) has these associated operations:

• create stack
• add item to stack (push)
• remove item from stack (pop)

The stack ADT is to be implemented as a linked list of nodes.

Each node consists of data and a pointer to the next node.

(a) There is one pointer: the top of stack pointer, which points to the last item added to the stack.
Draw a diagram to show the final state of the stack after the following operations are carried
out.

CreateStack
Push("Ali")
Push("Jack")
Pop
Push("Ben")
Push("Ahmed")
Pop
Push("Jatinder")

Add appropriate labels to the diagram to show the final state of the stack. Use the space on the left
as a workspace. Show your final answer in the node shapes on the right:

[3]

© UCLES 2015 9608/43/M/J/15


93
11

(b) Using pseudocode, a record type, Node, is declared as follows:

TYPE Node
DECLARE Name : STRING
DECLARE Pointer : INTEGER
ENDTYPE

The statement

DECLARE Stack : ARRAY[1:10] OF Node

reserves space for 10 nodes in array Stack.

(i) The CreateStack operation links all nodes and initialises the TopOfStackPointer
and FreePointer.

Complete the diagram to show the value of all pointers after CreateStack has been
executed.

Stack
TopOfStackPointer Name Pointer
[1]

[2]

FreePointer [3]

[4]

[5]

[6]

[7]

[8]

[9]

[10]
[4]

© UCLES 2015 9608/43/M/J/15 [Turn over


94
12

(ii) The algorithm for adding a name to the stack is written, using pseudocode, as a
procedure with the header

PROCEDURE Push (NewName)

Where NewName is the new name to be added to the stack. The procedure uses the
variables as shown in the identifier table.

Identifier Data type Description


Stack Array[1:10] OF Node
NewName STRING Name to be added
FreePointer INTEGER Pointer to next free node in array
TopOfStackPointer INTEGER Pointer to first node in stack
TempPointer INTEGER Temporary store for copy of FreePointer

PROCEDURE Push(BYVALUE NewName : STRING)


// Report error if no free nodes remaining
IF FreePointer = 0
THEN
Report Error
ELSE
// new name placed in node at head of free list
Stack[FreePointer].Name NewName ←
// take a temporary copy and
// then adjust free pointer
TempPointer ←
FreePointer
FreePointer ←
Stack[FreePointer].Pointer
// link current node to previous top of stack
Stack[TempPointer].Pointer ←
TopOfStackPointer
// adjust TopOfStackPointer to current node
TopOfStackPointer ←
TempPointer
ENDIF
ENDPROCEDURE

© UCLES 2015 9608/43/M/J/15


95
13

Complete the pseudocode for the procedure Pop. Use the variables listed in the identifier table.

PROCEDURE Pop()

// Report error if Stack is empty

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

OUTPUT Stack [.....................................................................................].Name

// take a copy of the current top of stack pointer

..........................................................................................................................................................

// update the top of stack pointer

..........................................................................................................................................................

// link released node to free list

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

ENDPROCEDURE
[5]

© UCLES 2015 9608/43/M/J/15 [Turn over


96
14

6 A recursively defined procedure X is defined below:

PROCEDURE X(BYVALUE n : INTEGER)


IF (n = 0) OR (n = 1)
THEN
OUTPUT n
ELSE
CALL X(n DIV 2)
OUTPUT (n MOD 2)
ENDIF
ENDPROCEDURE

(a) Explain what is meant by recursively defined.

...................................................................................................................................................

.............................................................................................................................................. [1]

(b) Explain how a stack is used during the execution of a recursive procedure.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [2]

(c) Dry run the procedure X by completing the trace table for the procedure call:

CALL X(40)

Call
n (n = 0) OR (n = 1) n DIV 2 n MOD 2
number
1 40 FALSE 20
2
3
4
5
6

OUTPUT ............................................................................................................................... [6]

© UCLES 2015 9608/43/M/J/15


97
15

(d) State the process that is carried out by procedure X.

...................................................................................................................................................

.............................................................................................................................................. [1]

(e) Write program code for procedure X.

Programming language .............................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [5]

© UCLES 2015 9608/43/M/J/15


98

CAMBRIDGE INTERNATIONAL EXAMINATIONS


Cambridge International Advanced Level

MARK SCHEME for the May/June 2015 series

9608 COMPUTER SCIENCE


9608/43 Paper 4 (Written Paper), maximum raw mark 75

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of
the examination. It shows the basis on which Examiners were instructed to award marks. It does not
indicate the details of the discussions that took place at an Examiners’ meeting before marking began,
which would have considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner
Report for Teachers.

Cambridge will not enter into discussions about these mark schemes.

Cambridge is publishing the mark schemes for the May/June 2015 series for most
Cambridge IGCSE®, Cambridge International A and AS Level components and some
Cambridge O Level components.

® IGCSE is the registered trademark of Cambridge International Examinations.


99
Page 2 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2015 9608 43

1
Take nozzle

start

Pump ready Pump in use

Press trigger

Replace nozzle

Reset pump display Stop pressing trigger

Pump out of use


Pump dispensing

[9]

2 (a) made_with(laasi, milk).


made_with(laasi, yogurt).
dairy_product(milk).
dairy_product(yogurt). [4]

(b) Ingredient =
cheese, egg, flour [2]

(c) contains_meat(Dish)
IF
made_with(Dish, X) (2 marks)
AND (1 mark)
meat(X) (1 mark) [4]

© Cambridge International Examinations 2015


100
Page 3 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2015 9608 43

3 (a)

Age under 25 Y Y Y Y N N N N
Conditions

Previous accident Y Y N N Y Y N N

Licence held for 3


Y N Y N Y N Y N
or more years

10% extra cost X


Actions

No discount X X X X

5% discount X X X

1 1 1 1
1 mark 1 mark
mark mark mark mark
[6]

(b)

Age under 25 Y Y Y Y N N
Conditions

Previous accident Y Y N N Y N

Licence held for 3


Y N Y N - -
or more years

10% extra cost X


Actions

No discount X X X

5% discount X X

1 1
1 mark
mark mark
[3]

© Cambridge International Examinations 2015


101
Page 4 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2015 9608 43

(c) Example Pascal

FUNCTION CostPercentageChange(DriverAge : INTEGER;


HadAccident : BOOLEAN; YearsLicenceHeld : INTEGER) : INTEGER;
BEGIN
IF DriverAge >= 25
THEN
IF HadAccident = TRUE
THEN
CostPercentageChange := 0
ELSE
CostPercentageChange := -5
ELSE
IF HadAccident = TRUE
THEN
IF YearsLicenceHeld < 3
THEN
CostPercentageChange := 10
ELSE
CostPercentageChange := 0
ELSE
IF YearsLicenceHeld < 3
THEN
CostPercentageChange := 0
ELSE
CostPercentageChange:= -5;
END;

Example Python

def CostPercentageChange(DriverAge, HadAccident, YearsLicenceHeld) :


if DriverAge >= 25:
if HadAccident:
return 0
else:
return -5
else:
if HadAccident:
if YearsLicenceHeld < 3:
return 10
else:
return 0
else:
if YearsLicenceHeld < 3:
return 0
else:
return -5;

© Cambridge International Examinations 2015


102
Page 5 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2015 9608 43

Mark as follows:
Correct function header
Correct IF statement (1)
Correct IF statement (2)
Correct IF statement (3)
Correct IF statement (4)
Correct IF statement (5)
Correct return statement (or equivalent) [max 6]
OR equivalent demonstrating correct logic

4 (a)

[3]

(b) Example Pascal

Member = CLASS
PUBLIC
Procedure SetMemberName;
Procedure SetMemberID;
Procedure SetSubscriptionPaid;
PRIVATE
MemberName : STRING;
MemberID : STRING;
SubscriptionPaid : Boolean;
END;

© Cambridge International Examinations 2015


103
Page 6 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2015 9608 43

Example Python

class Member() :
def__init__(self): PUBLIC
self.__MemberName = ""
self.__MemberID = ""
self.__SubscriptionPaid = False
def SetMemberName(self, Name):
self.MemberName = Name
def SetMemberID(self, ID):
self.MemberID = ID
def SetSubscriptionPaid(self, Paid):
self.SubscriptioPaid = Paid

Mark as follows:
Class header (1 mark)
Public and Private used correctly (1 mark)
MemberName + MemberID (1 mark)
SubscriptionPaid (1 mark)
Methods × 3 (1 mark) [5]

(c) (i) Example Pascal


JuniorMember = CLASS (Member)
PUBLIC
Procedure SetDateOfBirth;
PRIVATE
DateOfBirth : DateTime;
END;

Example Python
class JuniorMember (Member):
def__init__self:
super().__init__()
self.DateOfBirth = ""
def SetDateOfBirth(self, Date):
self.DateOfBirth = Date
def SetMemberName(self, Name):
super().SetMemberName(Name)
def SetMemberID(self, ID):
super().SetMemberID(ID)
def SetSubscriptionPaid(self, Paid):
super().SetSubscriptioPaid(Paid) [3]

© Cambridge International Examinations 2015


104
Page 7 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2015 9608 43

(ii) Example Pascal

NewMember := JuniorMember.Create; (1 mark)


NewMember.SetMemberName('Ahmed');
NewMember.SetMemberID('12347'); (1 mark)
NewMember.SetSubscriptionPaid(TRUE);
NewMember.SetDateOfBirth("12/11/2001"); (1 mark)

Example Python

NewMember := JuniorMember() (1 mark)


NewMember.SetMemberName("Ahmed")
NewMember.SetMemberID("12347") (1 mark)
NewMember.SetSubscriptionPaid(TRUE)
NewMember.SetDateOfBirth("12/11/2001") (1 mark) [3]

5 (a)

Top of
Stack Jatinder

Ben

Ali 0

1 mark for Top of Stack pointer


1 mark for 3 correct items
1 mark for correct order with null pointer in last node [3]

© Cambridge International Examinations 2015


105
Page 8 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2015 9608 43

(b) (i)

Stack

TopOfStackPointer Name Pointer

0 [1] 2

[2] 3

FreePointer [3] 4

1 [4] 5

[5] 6

[6] 7

[7] 8

[8] 9

[9] 10

[10] 0

Mark as follows:
TopOfStackPointer
FreePointer
Pointers[1] to [9]
Pointer[10] [4]

© Cambridge International Examinations 2015


106
Page 9 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2015 9608 43

(ii) PROCEDURE Pop()


// Report error if Stack is empty
IF TopOfStackPointer = 0
THEN
Error
ELSE
OUTPUT Stack[TopOfStackPointer].Name
// take a copy of the current top of stack pointer
TempPointer  TopOfStackPointer
// update the top of stack pointer
TopOfStackPointer  Stack[TempPointer].Pointer
// link released node to free list
Stack[TempPointer].Pointer  FreePointer
FreePointer  TempPointer
ENDIF
ENDPROCEDURE

1 mark for each line of code as above (first 4 lines + ENDIF for 1 mark) [Max 5]

6 (a) A procedure that calls itself // is defined in terms of itself [1]

(b) Before procedure call is executed current state of the registers/local variables is saved onto
the stack
When returning from a procedure call the registers/local variables are re-instated [2]

(c)

Call number n (n=0) OR (n=1) n DIV 2 n MOD 2

1 40 FALSE 20 0

2 20 FALSE 10 0

3 10 FALSE 5 0

4 5 FALSE 2 1

5 2 FALSE 1 0

6 1 TRUE

1 mark 1 mark 1 mark


OUTPUT 101000 – 1 mark for each pair of bits. [6]

(d) Conversion of denary number into binary [1]

© Cambridge International Examinations 2015


107
Page 10 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2015 9608 43

(e) (i) Example Pascal


Procedure X(n: INTEGER)
BEGIN
IF (n = 0) OR (n = 1)
THEN
Write(n)
ELSE
BEGIN
X(n DIV 2);
Write(n MOD 2);
END;
END;

Example Python
def X(n):
if (n == 0) or (n == 1):
print(n, end="")
else:
X(n // 2)
print(n % 2, end="")

Mark as follows:
Procedure heading & ending
Boolean expression
correctly grouped statements within ELSE
recursive call
Using DIV and MOD correctly [5]

© Cambridge International Examinations 2015


108

Cambridge International Examinations


Cambridge International Advanced Level
* 6 5 5 0 0 8 5 9 6 3 *

COMPUTER SCIENCE 9608/32


Paper 3 Advanced Theory October/November 2015
1 hour 30 minutes
Candidates answer on the Question Paper.
No Additional Materials are required.
No calculators allowed.

READ THESE INSTRUCTIONS FIRST

Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.

Answer all questions.


No marks will be awarded for using brand names of software packages or hardware.

At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.

The maximum number of marks is 75.

This document consists of 11 printed pages and 1 blank page.

DC (ST) 95544/3
© UCLES 2015 [Turn over
109
2

1 In a particular computer system, real numbers are stored using floating-point representation with:

• 8 bits for the mantissa, followed by


• 4 bits for the exponent

Two’s complement form is used for both mantissa and exponent.

(a) (i) A real number is stored as the following 12-bit binary pattern:

0 1 1 0 1 0 0 0 0 0 1 1

Calculate the denary value of this number. Show your working.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

(ii) Give the normalised binary pattern for +3.5. Show your working.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

(iii) Give the normalised binary pattern for –3.5. Show your working.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

© UCLES 2015 9608/32/O/N/15


110
3

The number of bits available to represent a real number is increased to 16.

(b) (i) If the system were to use the extra 4 bits for the mantissa, state what the effect would be
on the numbers that can be represented.

...........................................................................................................................................

.......................................................................................................................................[1]

(ii) If the system were to use the extra 4 bits for the exponent instead, state what the effect
would be on the numbers that can be represented.

...........................................................................................................................................

.......................................................................................................................................[1]

(c) A student enters the following expression into an interpreter:

OUTPUT (0.1 + 0.2)

The student is surprised to see the following output:

0.3000000000000001

Explain why this output has occurred.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

© UCLES 2015 9608/32/O/N/15 [Turn over


111
4

2 In this question, you are shown pseudocode in place of a real high-level language. A compiler
uses a keyword table and a symbol table. Part of the keyword table is shown below.

• Tokens for keywords are shown in hexadecimal.


• All the keyword tokens are in the range 00 to 5F.

Keyword Token
01
+ 02
= 03

IF 4A
THEN 4B
ENDIF 4C
ELSE 4D
FOR 4E
STEP 4F
TO 50
INPUT 51
OUTPUT 52
ENDFOR 53

Entries in the symbol table are allocated tokens. These values start from 60 (hexadecimal).

Study the following piece of code:

Start 0.1
// Output values in loop
FOR Counter Start TO 10
OUTPUT Counter + Start
ENDFOR

(a) Complete the symbol table below to show its contents after the lexical analysis stage.

Token
Symbol
Value Type

Start 60 Variable

0.1 61 Constant

[3]
© UCLES 2015 9608/32/O/N/15
112
5

(b) Each cell below represents one byte of the output from the lexical analysis stage.

Using the keyword table and your answer to part (a) complete the output from the lexical
analysis.

60 01
[2]

(c) The compilation process has a number of stages. The output of the lexical analysis stage
forms the input to the next stage.

(i) Name this stage.

.......................................................................................................................................[1]

(ii) State two tasks that occur at this stage.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(d) The final stage of compilation is optimisation. There are a number of reasons for performing
optimisation. One reason is to produce code that minimises the amount of memory used.

(i) State another reason for the optimisation of code.

.......................................................................................................................................[1]

(ii) What could a compiler do to optimise the following expression?

A B + 2 * 6

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[1]

© UCLES 2015 9608/32/O/N/15 [Turn over


113
6

(iii) These lines of code are to be compiled:

X A + B
Y A + B + C

Following the syntax analysis stage, object code is generated. The equivalent code, in
assembly language, is shown below:

LDD 436 //loads value A


ADD 437 //adds value B
STO 612 //stores result in X
LDD 436 //loads value A
ADD 437 //adds value B
ADD 438 //adds value C
STO 613 //stores result in Y

(iv) Rewrite the equivalent code, given above, following optimisation.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

© UCLES 2015 9608/32/O/N/15


114
7

3 (a) Explain what is meant by circuit switching.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(b) There are many applications in which digital data are transferred across a network. Video
conferencing is one of these.

For this application, circuit switching is preferable to the use of packet switching.

Explain why this is so.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[6]

(c) A web page is transferred from a web server to a home computer using the Internet.

Explain how the web page is transferred using packet switching.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]
© UCLES 2015 9608/32/O/N/15 [Turn over
115
8

4 (a) Four descriptions and four types of computer architecture are shown below.

Draw a line to connect each description to the appropriate type of computer architecture.

Description Computer architecture

A computer that does not have the ability for


SIMD
parallel processing.

The processor has several ALUs. Each ALU


executes the same instruction but on different MISD
data.

There are several processors. Each processor


executes different instructions drawn from a
SISD
common pool. Each processor operates on
different data drawn from a common pool.

There is only one processor executing one


MIMD
set of instructions on a single set of data.

[4]
(b) In a massively parallel computer explain what is meant by:

(i) Massive .............................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[1]

(ii) Parallel ..............................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[1]

(c) There are both hardware and software issues that have to be considered for parallel
processing to succeed.

Describe one hardware and one software issue.

Hardware ..................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Software ....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]
© UCLES 2015 9608/32/O/N/15
116
9

5 (a) (i) Complete the Boolean function that corresponds to the following truth table.

INPUT OUTPUT

P Q R Z

0 0 0 0

0 0 1 0

0 1 0 0

0 1 1 0

1 0 0 1

1 0 1 1

1 1 0 0

1 1 1 1

Z = P . Q . R + ................................................................................................................[3]

The part to the right of the equals sign is known as the sum-of-products.

(ii) For the truth table above complete the Karnaugh Map (K-map).

PQ

00 01 11 10

0
R
1
[1]

The K-map can be used to simplify the function in part(a)(i).

(iii) Draw loop(s) around appropriate groups of 1’s to produce an optimal sum-of-products.
[2]

(iv) Using your answer to part (a)(iii), write the simplified sum-of-products Boolean function.

Z = .................................................................................................................................[1]

© UCLES 2015 9608/32/O/N/15 [Turn over


117
10

(b) The truth table for a logic circuit with four inputs is given below:

INPUT OUTPUT
P Q R S Z
0 0 0 0 0
0 0 0 1 0
0 0 1 0 0
0 0 1 1 0
0 1 0 0 0
0 1 0 1 1
0 1 1 0 0
0 1 1 1 1
1 0 0 0 0
1 0 0 1 1
1 0 1 0 0
1 0 1 1 0
1 1 0 0 0
1 1 0 1 1
1 1 1 0 0
1 1 1 1 1

(i) Complete the K-map corresponding to the truth table above.

PQ

RS

[4]

(ii) Draw loop(s) around appropriate groups of 1’s to produce an optimal sum-of-products.
[2]

(iii) Using your answer to part (b)(ii), write the simplified sum-of-products Boolean function.

Z = .................................................................................................................................[2]

© UCLES 2015 9608/32/O/N/15


118
11

6 A number of processes are being executed in a computer.

A process can be in one of three states: running, ready or blocked.

(a) For each of the following, the process is moved from the first state to the second state.
Describe the conditions that cause each of the following changes of state of a process:

From blocked to ready ..............................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

From running to ready ..............................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]

(b) Explain why a process cannot move directly from the ready state to the blocked state.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

(c) A process in the running state can change its state to something which is neither the ready
state nor the blocked state.

(i) Name this state.

.......................................................................................................................................[1]

(ii) Identify when a process would enter this state.

.......................................................................................................................................[1]

(d) Explain the role of the low-level scheduler in a multiprogramming operating system.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]
© UCLES 2015 9608/32/O/N/15
119

CAMBRIDGE INTERNATIONAL EXAMINATIONS


Cambridge International Advanced Level

MARK SCHEME for the October/November 2015 series

9608 COMPUTER SCIENCE


9608/32 Paper 3 (Written Paper), maximum raw mark 75

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of
the examination. It shows the basis on which Examiners were instructed to award marks. It does not
indicate the details of the discussions that took place at an Examiners’ meeting before marking began,
which would have considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner
Report for Teachers.

Cambridge will not enter into discussions about these mark schemes.

Cambridge is publishing the mark schemes for the October/November 2015 series for most
Cambridge IGCSE®, Cambridge International A and AS Level components and some
Cambridge O Level components.

® IGCSE is the registered trademark of Cambridge International Examinations.


120
Page 2 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 32

1 (a) (i) 01101000 0011


= 0.1101 (or 1/2 + 1/4 + 1/16) × 23 [1+1]
= 110.1
= 6.5 [1]

(ii) +3.5
= 11.1 [1]
= 0.111 × 22 (or indication of moving binary point correctly) [1]
= 01110000 0010 [1]

(iii) 01110000 Allow f.t. from (ii)


10001111 One’s complement on mantissa [1]
10001111 +1 Two’s complement [1]

= 10010000 0010 [1]

(b) (i) Precision/accuracy of numbers represented will increase [1]

(ii) Range of numbers represented will increase [1]

(c) Any point, 1 mark (max. 3)

0.1/0.2 cannot be represented exactly in binary // rounding error [1]


0.1 represented by a value just greater than 0.1 // 0.2 represented by a value
just greater than 0.2 [1]
adding two representations together adds the two differences [1]
summed difference significant enough to be seen [1]
[max. 3]

[Total: 14]

2 (a)
Token
Symbol
Value Type

Start 60 Variable

0.1 61 Constant

Counter 62 Variable [1]

10 63 Constant [1+1]

© Cambridge International Examinations 2015


121
Page 3 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 32

(b)
60 01 61 4E 62 01 60 50 63 52 62 02 60 53
[1+1]

(c) (i) syntax analysis [1]

(ii) any two points from:

construct parse tree // parsing


checking syntax/grammar
produce error report [max. 2]

(d) (i) Minimise the execution time // code runs faster [1]

(ii) Compiler could calculate 2*6 and replace it with the value 12. [1]

(iii) LDD 436 }


ADD 437 } [1]
STO 612 }
ADD 438 [1]
STO 613 [1]

–1 for each additional instruction; 0 for copy of original code


[Total: 13]

3 (a) dedicated circuit/channel/physical path [1]


which lasts for duration of connection [1]

(b) e.g.
cs: gives dedicated circuit [1]
ps: split into packets/chunks [1]
ps: sends packets on individual routes [1]
cs: whole bandwidth available // ps: shares bandwidth [1]
cs: faster data transfer [1]
cs: packets arrive in order they are sent [1]
cs: packets cannot get lost [1]
cs: better for a real-time application [1]
ps: packets may arrive out of order so delay until packet order restored [1]
ps: packets may get lost so retransmission causes delays [1]
[max. 6]

(c) web page divided into packets/chunks [1]


each packet has destination address [1]
router looks at IP address… [1]
and decides where to send packet next for most efficient path [1]
packets can take different routes [1]
home computer reassembles packets to rebuild web page [1]
[max. 3]

© Cambridge International Examinations 2015


122
Page 4 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 32

[Total: 11]
4 (a) 1 mark for correct arrow from each description
Computer
Description Architecture

A computer that does not have


the ability for parallel SIMD
processing

The processor has several


ALUs. Each ALU executes the
MISD
same instruction but on
different data.

There are several processors.


Each processor executes
different instructions drawn
from a common pool. Each SISD
processor operates on different
data drawn from a common
pool.

There is only one processor


executing one set of
MIMD
instructions on a single set of
data.

[4]

(b) (i) Massive: many/large number of processors // hundreds/thousands of processors [1]

(ii) Parallel: to perform a set of coordinated computations in parallel/simultaneously [1]

(c) processors need to be able to communicate … [1]


so that processed data can be transferred from one processor to another [1]

suitable algorithm/program/software/design // appropriate programming language [1]


which allows data to be processed by multiple processors simultaneously [1]

[Total: 10]

© Cambridge International Examinations 2015


123
Page 5 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 32

5 (a) (i)
Z = P. Q . R + [1]
P. Q.R + [1]
P.Q.R [1]

(ii)
PQ

00 01 11 10

0 0 0 0 1
R
1 0 0 1 1
[1]

(iii) 1 mark each loop


PQ

00 01 11 10

0 0 0 0 1
R
1 0 0 1 1

Allow f.t. from (ii) [2]

(iv)
Z=
P. Q [1]
+ P.R [1]

Allow f.t. from (iii)

(b) (i) 1 mark row headings. 1 mark column headings.


1 mark per 2 correct rows (based on headings)
PQ

00 01 11 10

00 0 0 0 0

01 0 1 1 1
RS
11 0 1 1 0

10 0 0 0 0
[4]

© Cambridge International Examinations 2015


124
Page 6 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 32

(ii) 1 mark for loop with two 1s; 1 mark for loop with four 1s
PQ

00 01 11 10

00 0 0 0 0

01 0 1 1 1
RS
11 0 1 1 0

10 0 0 0 0

Allow f.t. from (i


–1 for each incorrect grouping, max. 2 errors [2]

(iii)
Z=
Q.S [1]
+ P.R. S [1]

Allow f.t. from (ii). –1 error if more than 2 terms


[Total: 16]

6 (a) blocked  ready:


process is waiting for resource/ I/O operation to complete (blocked state) [1]
when I/O operation completed process goes into ready queue (ready state) [1]
running  ready:
when process is executing it is allocated a time slice (running state) // process is allocated
time on processor [1]
when time slice completed/interrupt occurs process can no longer use processor even
though it is capable of further processing (ready state) [1]

(b) to be in blocked state process must initiate some I/O operation [1]
to initiate operation process must be executing [1]
if process in ready state cannot be executing/must be in running state [1]

(c) (i) exit/termination/completion [1]

(ii) when the process has finished execution [1]

(d) low-level scheduler:


decides which of the processes in ready state [1]
should get use of processor/be put in running state [1]
based on position/priority [1]
invoked after interrupt/OS call [1]
[max. 2]

[Total: 11]

© Cambridge International Examinations 2015


125

Cambridge International Examinations


Cambridge International Advanced Level
* 8 5 0 9 4 8 0 5 0 2 *

COMPUTER SCIENCE 9608/33


Paper 3 Advanced Theory October/November 2015
1 hour 30 minutes
Candidates answer on the Question Paper.
No Additional Materials are required.
No calculators allowed.

READ THESE INSTRUCTIONS FIRST

Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.

Answer all questions.


No marks will be awarded for using brand names of software packages or hardware.

At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.

The maximum number of marks is 75.

This document consists of 12 printed pages.

DC (NH) 117457
© UCLES 2015 [Turn over
126
2

1 In a particular computer system, real numbers are stored using floating-point representation with:

• 8 bits for the mantissa, followed by


• 8 bits for the exponent

Two’s complement form is used for both mantissa and exponent.

(a) (i) A real number is stored as the following two bytes:

Mantissa Exponent

0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 1

Calculate the denary value of this number. Show your working.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

(ii) Explain why the floating-point number in part (a)(i) is not normalised.

...........................................................................................................................................

.......................................................................................................................................[2]

(iii) Normalise the floating-point number in part (a)(i).

Mantissa Exponent

[2]

© UCLES 2015 9608/33/O/N/15


127
3

(b) (i) Write the largest positive number that can be written as a normalised floating-point
number in this format.

Mantissa Exponent

[2]

(ii) Write the smallest positive number that can be written as a normalised floating-point
number in this format.

Mantissa Exponent

[2]

(iii) If a positive number is added to the number in part (b)(i) explain what will happen.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(c) A student writes a program to output numbers using the following code:

X 0.0
FOR i 0 TO 1000
X X + 0.1
OUTPUT X
ENDFOR

The student is surprised to see that the program outputs the following sequence:

0.0 0.1 0.2 0.2999999 0.3999999 ……

Explain why this output has occurred.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

© UCLES 2015 9608/33/O/N/15 [Turn over


128
4

2 A compiler uses a keyword table and a symbol table. Part of the keyword table is shown below.

• Tokens for keywords are shown in hexadecimal.

• All the keyword tokens are in the range 00 – 5F.

Keyword Token
01
+ 02
= 03

IF 4A
THEN 4B
ENDIF 4C
ELSE 4D
FOR 4E
STEP 4F
TO 50
INPUT 51
OUTPUT 52
ENDFOR 53

Entries in the symbol table are allocated tokens. These values start from 60 (hexadecimal).

Study the following piece of code:

Counter 1.5
INPUT Num1
// Check values
IF Counter = Num1
THEN
Num1 Num1 + 5.0
ENDIF

(a) Complete the symbol table below to show its contents after the lexical analysis stage.

Token
Symbol
Value Type
Counter 60 Variable
1.5 61 Constant

[3]
© UCLES 2015 9608/33/O/N/15
129
5

(b) Each cell below represents one byte of the output from the lexical analysis stage.

Using the keyword table and your answer to part (a) complete the output from the lexical
analysis.

60 01
[2]

(c) This line of code is to be compiled:

A B + C + D

After the syntax analysis stage, the compiler generates object code. The equivalent code, in
assembly language, is shown below:

LDD 234 //loads value B


ADD 235 //adds value C
STO 567 //stores result in temporary location
LDD 567 //loads value from temporary location
ADD 236 //adds value D
STO 233 //stores result in A

(i) Name the final stage in the compilation process that follows this code generation stage.

.......................................................................................................................................[1]

(ii) Rewrite the equivalent code given above to show the effect of it being processed through
this final stage.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(iii) State two benefits of the compilation process performing this final stage.

Benefit 1 ............................................................................................................................

...........................................................................................................................................

Benefit 2 ............................................................................................................................

.......................................................................................................................................[2]

© UCLES 2015 9608/33/O/N/15 [Turn over


130
6

3 An email is sent from one email server to another using packet switching.

(a) State two items that are contained in an email packet apart from the data.

1 ................................................................................................................................................

2 ............................................................................................................................................[2]

(b) Explain the role of routers in sending an email from one email server to another.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

(c) Sending an email message is an appropriate use of packet switching.

Explain why this is the case.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(d) Packet switching is not always an appropriate solution.

Name an alternative communication method of transferring data in a digital network.

...............................................................................................................................................[1]

© UCLES 2015 9608/33/O/N/15


131
7

(e) Name an application for which the method identified in part (d) is an appropriate solution.
Justify your choice.

Application ................................................................................................................................

Justification ...............................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

© UCLES 2015 9608/33/O/N/15 [Turn over


132
8

4 (a) Three descriptions and two types of processor are shown below.

Draw a line to connect each description to the appropriate type of processor.

Description Type of processor

Makes extensive use of


RISC
general purpose registers

Many addressing modes


CISC
are available

Has a simplified set of


instructions
[3]

(b) In a RISC processor three instructions (A followed by B, followed by C) are processed using
pipelining.

The following table shows the five stages that occur when instructions are fetched and
executed.

(i) The ‘A’ in the table indicates that instruction A has been fetched in time interval 1.

Complete the table to show the time interval in which each stage of each instruction (A,
B, C) is carried out.

Time interval
Stage 1 2 3 4 5 6 7 8 9
Fetch instruction A
Decode instruction
Execute instruction
Access operand in memory
Write result to register
[3]

(ii) The completed table shows how pipelining allows instructions to be carried out more
rapidly. Each time interval represents one clock cycle.

Calculate how many clock cycles are saved by the use of pipelining in the above example.

Show your working.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]
© UCLES 2015 9608/33/O/N/15
133
9

5 (a) (i) Complete the Boolean function that corresponds to the following truth table.

INPUT OUTPUT

A B C X

0 0 0 0

0 0 1 0

0 1 0 0

0 1 1 1

1 0 0 0

1 0 1 0

1 1 0 1

1 1 1 1

X = A . B . C + ................................................................................................................[3]

The part to the right of the equals sign is known as the sum-of-products.

(ii) For the truth table above complete the Karnaugh Map (K-map).

AB

00 01 11 10

0
C
1
[1]

The K-map can be used to simplify the function in part(a)(i).

(iii) Draw loop(s) around appropriate groups of 1’s to produce an optimal sum-of-products.
[2]

(iv) Using your answer to part (a)(iii), write the simplified sum-of-products Boolean function.

X = .................................................................................................................................[2]

© UCLES 2015 9608/33/O/N/15 [Turn over


134
10

(b) The truth table for a logic circuit with four inputs is given below:

INPUT OUTPUT
A B C D X
0 0 0 0 0
0 0 0 1 0
0 0 1 0 0
0 0 1 1 0
0 1 0 0 1
0 1 0 1 0
0 1 1 0 1
0 1 1 1 0
1 0 0 0 0
1 0 0 1 0
1 0 1 0 0
1 0 1 1 0
1 1 0 0 1
1 1 0 1 0
1 1 1 0 1
1 1 1 1 1

(i) Complete the K-map corresponding to the truth table above.

AB

CD

[4]

(ii) Draw loop(s) around appropriate groups of 1’s to produce an optimal sum-of-products.
[2]

(iii) Using your answer to part (b)(ii), write the simplified sum-of-products Boolean function.

X = .................................................................................................................................[2]

© UCLES 2015 9608/33/O/N/15


135
11

6 A number of processes are being executed in a computer.

(a) Explain the difference between a program and a process.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

A process can be in one of three states: running, ready or blocked.

(b) For each of the following, the process is moved from the first state to the second state.
Describe the conditions that cause each of the following changes of the state of a process:

From running to ready ..............................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

From ready to running ..............................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

From running to blocked ...........................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[6]

© UCLES 2015 9608/33/O/N/15 [Turn over


136
12

(c) Explain why a process cannot be moved from the blocked state to the running state.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

(d) Explain the role of the high-level scheduler in a multiprogramming operating system.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

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 International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.

Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.

© UCLES 2015 9608/33/O/N/15


137

CAMBRIDGE INTERNATIONAL EXAMINATIONS


Cambridge International Advanced Level

MARK SCHEME for the October/November 2015 series

9608 COMPUTER SCIENCE


9608/33 Paper 3 (Written Paper), maximum raw mark 75

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of
the examination. It shows the basis on which Examiners were instructed to award marks. It does not
indicate the details of the discussions that took place at an Examiners’ meeting before marking began,
which would have considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner
Report for Teachers.

Cambridge will not enter into discussions about these mark schemes.

Cambridge is publishing the mark schemes for the October/November 2015 series for most
Cambridge IGCSE®, Cambridge International A and AS Level components and some
Cambridge O Level components.

® IGCSE is the registered trademark of Cambridge International Examinations.


138
Page 2 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 33

1 (a) (i) 00101000 00000011


=0.0101 × 2 ↑3 [1]
=10.1 [1]
=2.5 [1]

(ii) For a positive number (mantissa starts with a zero) [1]


bit after binary point (second bit from left) should be a one [1]

(iii) 00101000 00000011


= 01010000 00000010 [1+1]

(b) (i) 01111111 0111111 [1+1]

(ii) 01000000 1000000 [1+1]

(iii) number will become too large to represent [1]


which will result in overflow [1]

(c) Any point 1 mark

0.1 cannot be represented exactly in binary


0.1 represented here by a value just less than 0.1
the loop keeps adding this approximate value to counter
until all accumulated small differences become significant enough to be seen
[max 3]

2 (a)
Token
Symbol
Value Type
Counter 60 variable

1.5 61 constant

Num1 62 variable [1]

5.0 63 constant [1+1]

(b)
6 0 6 5 6 4 6 0 6 4 6 0 6 0 6 4
0 1 1 1 2 A 0 3 2 B 2 1 2 2 3 C [1+1]

© Cambridge International Examinations 2015


139
Page 3 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 33

(c) (i) Code optimisation [1]

(ii) LDD 234


ADD 235 [1]
ADD 236
STO 233 [1]

1 mark for first 2 lines, 1 mark for last 2 lines, with no other lines added

(iii) Code has fewer instructions / occupies less space in memory when executed [1]
minimises execution time of code // code will execute faster [1]

3 (a) Any point 1 mark

sender’s IP address
receiver’s IP address
packet sequence number
checksum
[Max 2]

(b) Any point 1 mark

email has been split up into packets


packet has destination address
packets pass through many different routers in journey
packets don’t take same route
routers use IP addresses
packets reassembled at destination to rebuild email
[Max 3]

(c) Any point 1 mark

email message is only read when all of it is received


time delays due to lost / delayed packets not significant
so sending different packets by different routes is not issue / is efficient
packets arriving out of order not an issue
no requirement for a continuous circuit (circuit switching)
[Max 2]

(d) Circuit switching [1]

(e) e.g. real-time video / video conferencing [1]

Any point 1 mark

circuit made available is dedicated to this communication stream


full bandwidth available / no sharing
no lost packets
guaranteed quality of service [Max 2]

© Cambridge International Examinations 2015


140
Page 4 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 33

4 (a)
Description Type of
processor
Makes extensive use of
general purpose registers RISC I mark for
correct arrow
from each
description

Many addressing modes


are available CISC

Has a simplified
instruction set
[3]

(b) (i)
Time Interval

stage 1 2 3 4 5 6 7 8 9

Fetch instruction A B C

Decode instruction A B C

Execute instruction A B C Completing the As


(1 Mark)

Access operand in memory A B C B in column 2,


Row 1 (1 Mark)

Write result to register A B C Remainder completed


(1 Mark)
[3]

(ii) With pipelining no of cycles = 7 [1]


Without pipelining no of cycles = 3 * 5 = 15 [1]
No of cycles saved = 8 [1]

© Cambridge International Examinations 2015


141
Page 5 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 33

5 (a) (i) A .B.C + [1]


A.B. C [1]
+
A.B.C [1]

(ii)
AB

00 01 11 10

0 0 0 1 0
C
1 0 1 1 0 [1]

(iii)
AB

00 01 11 10

0 0 0 1 0 1 mark for each loop


C
1 0 1 1 0

Allow f.t. from (ii)


[2]

(iv) X =
A.B [1]
+ B.C [1]
Allow f.t. from (iii)

© Cambridge International Examinations 2015


142
Page 6 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 33

(b) (i)
AB

00 01 11 10
1 mark row headings
00 0 1 1 0
1 mark column headings
01 0 0 0 0
CD 1 mark per 2 correct
rows (based on headings)
11 0 0 1 0

10 0 1 1 0

[4]
(ii)
AB

00 01 11 10

1 1 mark for loop with two 1s


00 0 1 0

1 mark for looping the four 1s


01 0 0 0 0
CD
1
11 0 0 0

10 0 1 1 0

[2]

(iii) X =
B.D [1]
+ A.B.C [1]

© Cambridge International Examinations 2015


143
Page 7 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 33

6 (a) A program is the written code (“static”) [1]


A process is the executing code (“dynamic”) [1]

(b) running, ready:


when process is executing it is allocated a time slice (running state) // process is allocated
time on processor [1]
when time slice completed process / interrupt occurs can no longer use processor even
though it is capable of further processing (ready state) [1]

ready, running:
process is capable of using processor (ready state) [1]
OS allocates processor to process so that process can execute (running state) [1]

running, blocked:
process is executing (running state) when it needs to perform I / O operation [1]
placed in blocked state – until I / O operation completed [1]

(c) when I / O operation completed for process in blocked state [1]


process put in ready state [1]
OS decides which process to allocate to processor from the ready queue [1]

(d) high-level scheduler:


decides which processes are to be loaded from backing store [1]
into memory / ready queue [1]

© Cambridge International Examinations 2015


144

Cambridge International Examinations


Cambridge International Advanced Level

COMPUTER SCIENCE 9608/42


Paper 4 Further Problem-solving and Programming Skills October/November 2015
PRE-RELEASE MATERIAL
* 3 4 2 4 0 1 8 7 4 3 *

This material should be given to candidates on receipt by the Centre.

READ THESE INSTRUCTIONS FIRST

Candidates should use this material in preparation for the examination. Candidates should attempt the
practical programming tasks using their chosen high-level, procedural programming language.

This document consists of 9 printed pages and 3 blank pages.

DC (NH/SW) 111478
© UCLES 2015 [Turn over
145
2

This material is intended to be read by teachers and candidates prior to the November 2015 examination
for 9608 Paper 4.

Reminders
The syllabus states:
• there will be questions on the examination paper which do not relate to this pre-release
material
• you must choose a high-level programming language from this list:
ͦ Visual Basic (console mode)
ͦ Python
ͦ Pascal / Delphi (console mode)

The practical skills covered in Paper 2 are a precursor to those required in Paper 4. It is therefore
recommended that the high-level programming language chosen for this paper is the same as that for
Paper 2. This allows for sufficient expertise to be acquired with the opportunity for extensive practice.

Questions on the examination paper may ask the candidate to write:


• structured English
• pseudocode
• program code

A program flowchart should be considered as an alternative to pseudocode for the documenting of an


algorithm design.

Candidates should be confident with:


• the presentation of an algorithm using either a program flowchart or pseudocode
• the production of a program flowchart from given pseudocode or the reverse

© UCLES 2015 9608/42/PRE/O/N/15


146
3

TASK 1

The taxis used by a taxi company are either cars or minibuses.

The unique registration and the charge (in $) per unit time are stored for all taxis.

All cars can carry a maximum of four passengers.

Data stored about minibuses also includes an extra charge (in $) per booking and the maximum
number of passengers allowed.

The company needs software to process data about taxis.

The processing needs to include a calculation of the fare charged.

The software will be object-oriented.

The superclass (also known as base class or parent class) Taxi is designed.

Two subclasses (also known as derived classes or child classes) have been identified:

• Car
• Minibus
Key focus: Object-oriented Programming
TASK 1.1
Complete the inheritance diagram.

© UCLES 2015 9608/42/PRE/O/N/15 [Turn over


147
4

TASK 1.2
Complete the class diagram showing the appropriate properties and methods.

.......................................................................

.......................................................................

.......................................................................

.......................................................................

.......................................................................

.......................................................................

.......................................................................

....................................................................... .......................................................................

....................................................................... .......................................................................

....................................................................... .......................................................................

....................................................................... .......................................................................

Constructor() .......................................................................

....................................................................... .......................................................................

....................................................................... .......................................................................

....................................................................... .......................................................................

Note: a constructor is a method that creates a new instance of a class and initialises it.

TASK 1.3
Write program code for the class definitions. Make use of polymorphism and inheritance where
appropriate.

TASK 1.4
Write program code to create a new instance of Car.

Suggested extension task


Write program code to display the properties of the object you created in Task 1.4.

© UCLES 2015 9608/42/PRE/O/N/15


148
5

TASK 2

Key focus: Project management using


PERT and GANTT charts
A software program is to be written for a client.

A detailed program specification has been written. The program will consist of seven different menu
options handled from a main module by calling seven different procedures. These modules can be
coded independently.

All procedures and the main module are each estimated to take 3 hours to code and 2 hours to test.

Integration testing is expected to take 3 hours and Alpha testing 7 hours.

TASK 2.1
The project manager initially has one programmer available to write and test the program. The
programmer works 10 hours a day. Calculate how many days it takes before the customer can start
acceptance testing.

TASK 2.2
The customer is not happy about the proposed development time and the project manager considers
hiring extra staff.

One proposal is to deploy one programmer and one software tester to the project.

The project manager needs a PERT chart to calculate the critical path.

Complete the diagram below.

1 3 4 5

2
Key focus: Project management
using a PERT chart

Note: the arrow denotes a dummy activity.

Write the critical path.

Calculate the shortest time (in days) before the client can start acceptance testing.

© UCLES 2015 9608/42/PRE/O/N/15 [Turn over


149
6

TASK 2.3
Another proposal is to deploy four programmers, who each carry out their own module testing.

TASK 2.3.1
Draw a GANTT chart for this proposal.
Key focus: Project management using
a GANTT chart

Activity

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Hour number
1
2
3
4
5
6
7
8
9

TASK 2.3.2
If the programmers each work 10 hours a day, calculate how many days it takes before the customer
can start acceptance testing.

Suggested extension task


Try other proposals, such as only a software tester can carry out any testing.
Activity
Code P1
Test P1
Code P2
Test P2
Code P3
Test P3
Code P4
Test P4
Code P5
Test P5
Code P6
Test P6
Code P7
Test P7
Code P8
Test P8
Integration testing
Alpha testing
Hour number
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
1
2
3
4
5
6
7
8
9

© UCLES 2015 9608/42/PRE/O/N/15


150
7

TASK 3

Data about books are stored in a random file of records.

• The key field of a book record is the ISBN (a 9-digit string and a check digit).
• Other book data are stored.
• A hashing function is used to calculate a record address.
(The first 3 digits of the ISBN are used as the record address.)
• The random file initially consists of dummy records.
• Dummy records are shown by the ISBN set to 0000000000.

FUNCTION Hash(ISBN : STRING) RETURNS INTEGER


Address ← LeftToInt(ISBN, 3)
RETURN Address Key focus: Random files
ENDFUNCTION

The Hash function assumes the existence of the function LeftToInt, defined below:

LeftToInt(ThisString : STRING, n: INTEGER) RETURNS INTEGER


returns an integer calculated from the n-digit string, starting from the left of the string ThisString.

An error is returned if:


- any of the first n characters of ThisString are non-digit characters
- the length of ThisString is less than n

For example: LeftToInt("1575697620", 3) returns the integer 157

Note: Random files are also known as direct access files.

TASK 3.1
Write program code to implement the functions LeftToInt and Hash.

© UCLES 2015 9608/42/PRE/O/N/15 [Turn over


151
8

TASK 3.2
Write program code to implement the following pseudocode which initialises a random file:

TYPE BookRecord
DECLARE ISBN : STRING[10] // need fixed-length records for
DECLARE Title : STRING[24] // random files
DECLARE OnLoan : BOOLEAN
ENDTYPE

DECLARE DummyRecord : BookRecord

DummyRecord.ISBN ← "0000000000"

OPENFILE "BookFile" FOR WRITE // create the file by sequentially


// writing dummy records to the new file
// prior to use as a random file
FOR Count ← 1 TO 1000
PUTRECORD "BookFile", DummyRecord
ENDFOR
CLOSEFILE "BookFile"

TASK 3.3
Write program code to implement the following pseudocode to input 5 book records:

010 DECLARE NewBook : BookRecord


020
030 OPENFILE "BookFile" FOR RANDOM
040 FOR Count ← 1 TO 5
050 INPUT NewBook.ISBN
060 INPUT NewBook.Title
070 NewAddress ← Hash(NewBook.ISBN)
080 SEEK "BookFile", NewAddress
090 PUTRECORD "BookFile", NewBook
100 ENDFOR
110 CLOSEFILE "BookFile"

Test your program by inputting book details with ISBNs that will hash to different addresses.

TASK 3.4
You need to test that the records have been saved successfully.

Write program code to read records sequentially from the random file BookFile and output any non-
zero records.
© UCLES 2015 9608/42/PRE/O/N/15
152
9

TASK 3.5
Key focus: Exception handling

If a program tries to open a non-existent file, a run-time error will occur.

To avoid this, you need to write exception handling code to give an error message instead.

Edit your program code from Task 3.3 to handle the case when "BookFile" does not exist.

TASK 3.6
Add a book record with an ISBN that will cause a collision (also known as a synonym).

Run your program from Task 3.4 again. What do you notice?

TASK 3.7
The pseudocode in Task 3.3 needs amending to handle a collision.

The following algorithm needs to be inserted between line 080 and 090.

Write pseudocode for the following structured English algorithm:

Repeat until useable address found, or file is full:


If there is a record with a non-zero ISBN at the address hashed
Go to the next record address
If the end of the file is reached, start at the beginning of the file
If the hashed address is reached again, the file is full

Write program code for your algorithm and test it.

Suggested extension task


Write program code to extend your program from Task 3.5 so your program will successfully add and
delete book records, even if their ISBNs cause collisions.

© UCLES 2015 9608/42/PRE/O/N/15


153

Cambridge International Examinations


Cambridge International Advanced Level
* 9 9 1 0 9 5 5 7 2 3 *

COMPUTER SCIENCE 9608/42


Paper 4 Further Problem-solving and Programming Skills October/November 2015

2 hours
Candidates answer on the Question Paper.
No Additional Materials are required.
No calculators allowed.

READ THESE INSTRUCTIONS FIRST

Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.

Answer all questions.


No marks will be awarded for using brand names of software packages or hardware.

At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.

The maximum number of marks is 75.

This document consists of 15 printed pages and 1 blank page.

DC (AC) 95228/3
© UCLES 2015 [Turn over
154
2

Throughout the paper you will be asked to write either pseudocode or program code.

Complete the statement to indicate which high-level programming language you will use.

Programming language ……………………………………………….………….………….………….………

1 A large software house has been asked to supply a computerised solution for a business. The
project manager has drawn up a list of activities and their likely duration.

Weeks to
Activity Description
complete
A Write requirement specification 1
B Produce program design 1
C Write module code 7
D Module testing 2
E Integration testing 2
F Alpha testing 2
G Install software and carry out acceptance testing 2
H Research and order hardware 1
J Install delivered hardware 3
K Write technical documentation 4
L Write user training guide 2
M Train users on installed hardware and software 1
N Sign off final system 1

(a) From this data a GANTT chart is constructed.

Activity
A
B
C
D
E
F
G
H
J
K
L
M
N
Week
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

number
1
2
3
4
5
6
7
8
9

© UCLES 2015 9608/42/O/N/15


155
3

(i) Complete the GANTT chart by adding activities M and N. [2]

(ii) State the earliest completion date.

Week number ............................................................................................................... [1]

(b) There are problems with the progress of the project:

• Activity E showed that the code contained major errors. The senior programmer now
estimates that:
• further module coding will require another 2 weeks
• further module testing will require another 2 weeks
• further integration testing will require another 2 weeks
• The hardware delivery is delayed by 16 weeks.

A revised GANTT chart is now required.

(i) Complete the chart in the grid below.

Activity
A
B
C
D
E
F
G
H
J
K
L
M
N
Week
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

number
1
2
3
4
5
6
7
8
9

[9]

(ii) State the new estimated completion date.

Week number ................................................................................................................ [1]

© UCLES 2015 9608/42/O/N/15 [Turn over


156
4

2 A declarative programming language is used to represent the following facts and rules:

01 male(ahmed).
02 male(raul).
03 male(ali).
04 male(philippe).
05 female(aisha).
06 female(gina).
07 female(meena).
08 parent(ahmed, raul).
09 parent(aisha, raul).
10 parent(ahmed, philippe).
11 parent(aisha, philippe).
12 parent(ahmed, gina).
13 parent(aisha, gina).
14 mother(A, B) IF female(A) AND parent(A, B).

These clauses have the following meaning:

Clause Explanation
01 Ahmed is male
05 Aisha is female
08 Ahmed is a parent of Raul
14 A is the mother of B if A is female and A is a parent of B

(a) More facts are to be included.

Ali and Meena are the parents of Ahmed.

Write the additional clauses to record this.

15 ............................................................................................................................................

16 ....................................................................................................................................... [2]

(b) Using the variable C, the goal

parent(ahmed, C)

returns

C = raul, philippe, gina

Write the result returned by the goal

parent(P, gina)

P = ....................................................................................................................................... [2]

© UCLES 2015 9608/42/O/N/15


157
5

(c) Use the variable M to write the goal to find the mother of Gina.

.............................................................................................................................................. [1]

(d) Write the rule to show that F is the father of C.

father(F, C)

IF .............................................................................................................................................

.............................................................................................................................................. [2]

(e) Write the rule to show that X is a brother of Y.

brother(X, Y)

IF .............................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [4]

© UCLES 2015 9608/42/O/N/15 [Turn over


158
6

3 A college has two types of student: full-time and part-time.

All students have their name and date of birth recorded.

A full-time student has their address and telephone number recorded.

A part-time student attends one or more courses. A fee is charged for each course. The number of
courses a part-time student attends is recorded, along with the total fee and whether or not the fee
has been paid.

The college needs a program to process data about its students. The program will use an object-
oriented programming language.

(a) Complete the class diagram showing the appropriate properties and methods.

Student

StudentName: STRING

........................................................................

........................................................................

........................................................................

ShowStudentName()

........................................................................

........................................................................

........................................................................

FullTimeStudent PartTimeStudent

Address: STRING
.......................................................................
.......................................................................
.......................................................................
.......................................................................
.......................................................................
.......................................................................
.......................................................................

Constructor()
.......................................................................
ShowAddress()
.......................................................................
.......................................................................
.......................................................................
.......................................................................
.......................................................................
[7]
© UCLES 2015 9608/42/O/N/15
159
7

(b) Write program code:

(i) for the class definition for the superclass Student.

Programming language .....................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [2]

(ii) for the class definition for the subclass FullTimeStudent.

Programming language .....................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [3]

© UCLES 2015 9608/42/O/N/15 [Turn over


160
8

(iii) to create a new instance of FullTimeStudent with:

• identifier: NewStudent
• name: A. Nyone
• date of birth: 12/11/1990
• telephone number: 099111

Programming language .....................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [3]

4 A dictionary Abstract Data Type (ADT) has these associated operations:

• Create dictionary (CreateDictionary)


• Add key-value pair to dictionary (Add)
• Delete key-value pair from dictionary (Delete)
• Lookup value (Lookup)

The dictionary ADT is to be implemented as a two-dimensional array. This stores key-value pairs.

The pseudocode statement

DECLARE Dictionary : Array[1:2000, 1:2] OF STRING

reserves space for 2000 key-value pairs in array Dictionary.

The CreateDictionary operation initialises all elements of Dictionary to the empty string.

(a) The hashing function Hash is to extract the first letter of the key and return the position of this
letter in the alphabet. For example Hash("Action") will return the integer value 1.
(Note: The ASCII code for the letter A is 65.)

Complete the pseudocode:

FUNCTION Hash (................................................) RETURNS .............................................

DECLARE Number : INTEGER

Number ← ...........................................................................................................................

............................................................................................................................................

ENDFUNCTION
[5]

© UCLES 2015 9608/42/O/N/15


161
9

(b) The algorithm for adding a new key-value pair to the dictionary is written, using pseudocode,
as a procedure.

PROCEDURE Add(NewKey : STRING, NewValue : STRING)


Index ← Hash(NewKey)
Dictionary[Index, 1] ← NewKey // store the key
Dictionary[Index, 2] ← NewValue // store the value
ENDPROCEDURE

An English-German dictionary of Computing terms is to be set up.

(i) Dry-run the following procedure calls by writing the keys and values in the correct
elements of Dictionary.

Add("File", "Datei")
Add("Disk", "Platte")
Add("Error", "Fehler")
Add("Computer", "Rechner")

Dictionary
Index Key Value
1
2
3
4
5
6
7
8
:
:
1999
2000
[2]

(ii) Another procedure call is made: Add("Drive", "Laufwerk")

Explain the problem that occurs when this key-value pair is saved.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [2]
© UCLES 2015 9608/42/O/N/15 [Turn over
162
10

(iii) Describe a method to handle the problem identified in part (b)(ii).

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(iv) Write pseudocode to implement the method you described in part (b) (iii). Choose line
numbers to indicate where your pseudocode should be inserted in the given pseudocode.

10 PROCEDURE Add(NewKey : STRING, NewValue : STRING)

20 Index ← Hash(NewKey)

30 Dictionary[Index, 1] ← NewKey // store the key

40 Dictionary[Index, 2] ← NewValue // store the value

50 ENDPROCEDURE

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [4]

© UCLES 2015 9608/42/O/N/15


163
11

Question 5 begins on page 12.

© UCLES 2015 9608/42/O/N/15 [Turn over


164
12

5 The table shows assembly language instructions for a processor which has one general purpose
register – the Accumulator (ACC).

Instruction
Explanation
Op Code Operand
LDM #n Immediate addressing. Load the number n to ACC
LDD <address> Direct addressing. Load the contents of the given address to ACC
STO <address> Store the contents of ACC at the given address
ADD <address> Add the contents of the given address to the ACC
INC <register> Add 1 to the contents of the register
CMP <address> Compare the contents of ACC with the contents of <address>
JPN <address> Following a compare instruction, jump to <address> if the compare
was False
END Return control to the operating system

(a) (i) Dry-run this assembly language program using the trace table.

500 LDD 512

501 ADD 509

502 STO 512

503 LDD 511

504 INC ACC

505 STO 511

506 CMP 510

507 JPN 500

508 END

509 7

510 3

511 0

512 0

© UCLES 2015 9608/42/O/N/15


165
13

Trace table

Memory address
Accumulator 509 510 511 512
7 3 0 0

[5]

(ii) Explain the role address 511 has in this assembly language program.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [2]

(b) Using opcodes from the given table, write instructions to set the value at address 509 to 12.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [2]

© UCLES 2015 9608/42/O/N/15 [Turn over


166
14

6 A company keeps details of its stock items in a file of records, StockFile.

(a) The record fields are the ProductCode, the Price and the NumberInStock.

Write the program code to declare the record structure StockItem.

Programming language ............................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [4]

(b) Before records can be read from file StockFile, the file needs to be opened.

(i) Complete the pseudocode.

01 TRY

02 OPENFILE ...........................................................................................................

03 EXCEPT

04 ..............................................................................................................................

05 ENDTRY
[2]

(ii) Explain the reason for including lines 01, 03, 04, 05.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [2]

© UCLES 2015 9608/42/O/N/15


167
15

(c) A stock report program uses a variable of type StockItem declared as follows:

DECLARE ThisStockItem : Stockitem

The program reads each record in the file StockFile in turn.

The program outputs the fields ProductCode and NumberInStock for each record.

Write pseudocode for this.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [4]

© UCLES 2015 9608/42/O/N/15


168

CAMBRIDGE INTERNATIONAL EXAMINATIONS


Cambridge International Advanced Level

MARK SCHEME for the October/November 2015 series

9608 COMPUTER SCIENCE


9608/42 Paper 4 (Written Paper), maximum raw mark 75

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of
the examination. It shows the basis on which Examiners were instructed to award marks. It does not
indicate the details of the discussions that took place at an Examiners’ meeting before marking began,
which would have considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner
Report for Teachers.

Cambridge will not enter into discussions about these mark schemes.

Cambridge is publishing the mark schemes for the October/November 2015 series for most
Cambridge IGCSE®, Cambridge International A and AS Level components and some
Cambridge O Level components.

® IGCSE is the registered trademark of Cambridge International Examinations.


169
Page 2 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 42

1 (a) (i)
Activity
A
B
C
D
E
F
G
H
J
K
L
M
N
Week
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Number
1
2
3
4
5
6
7
8
9

1 mark for each square [2]

(ii) week number 18

Allow follow through [1]

© Cambridge International Examinations 2015


170
Page 3 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 42

(b) (i)
Activity Description Weeks to
complete
A Write requirement specification 1
B Produce program design 1
C Write module code 7
D Module testing 2
E Integration testing 2
F Alpha testing 2
G Install software and carry out acceptance testing 2
H Research and order hardware 1
J Install delivered hardware 3
K Write technical documentation 4
L Write user training guide 2
M Train users on installed hardware and software 1
N Sign off final system 1

Activity
A
B
C
D
E
F
G
H
J
K
L
M
N
Week
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
1
2
3
4
5
6
7
8
9

Number

1 mark per activity (but 1 mark for activity M and N)


Notes:
C must be after E (1 or 2 later is ok)
D, E, F correct relative to C
J must start in week 20 (allow 21, 22)
G must come after the end of J (f.t.)
K finishes after or at same time as F
L finishes at the same time as G and after the end of J (or 1-2 weeks later)
M starts when everything else has finished. N after or at same time as M [9]

(ii) week number: 26

Allow f.t. [1]

© Cambridge International Examinations 2015


171
Page 4 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 42

2 (a) parent(ali, ahmed).


parent(meena, ahmed).

Accept statements in either order


Wrong capitalisation minus 1 mark [2]

(b) P =
ahmed
aisha

Ignore capitalisation
Deduct 1 mark for every extra result [2]

(c) mother(M, gina).

Accept parent(M, gina) AND female(M). Accept a comma instead of AND


Reject mother(M, gina) IF female(M) AND parent(M, gina).
Ignore capitalisation [1]

(d) father(F, C)
IF
male(F) AND parent(F, C).

(1) (1) [2]

(e) brother(X, Y)
IF
male(X)AND [1]
parent(A, X) AND [1]
parent(A, Y) [1]
AND NOT X=Y. [1]

Accept any variable for A, but it must be the same in both places
Accept father/mother instead of parent
Ignore capitalisation

© Cambridge International Examinations 2015


172
Page 5 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 42

3 (a)
Student
StudentName : STRING
DateOfBirth : DATETIME
………………………………………………………………………………………

ShowStudentName()
ShowDateOfBirth()
………………………………………………………………………………………

FullTimeStudent PartTimeStudent
Address: STRING NumberOfCourses : INTEGER
TelephoneNumber : STRING Fee : Currency
……………………………………………………………………………………… FeePaid : BOOLEAN

Constructor() Constructor()
ShowAddress() ShowNumberOFCourses()
ShowTelephoneNumber() ShowFee()
……………………………………………………………………………………… ShowFeePaid()

Mark as follows:

Base class:
– dateOfBirth declaration and associated method in Student
– constructor
Subclasses:
– telephoneNumber declaration and associated method in FullTimeStudent
– NumberOFCourses declaration and associated method in PartTimeStudent
– fee declaration and associated method in PartTimeStudent
– feepaid declaration and associated method in PartTimeStudent
– constructor method in PartTimeStudent
– inheritance arrows

Ignore data types, ignore other methods/attributes


Ignore brackets after methods [Max 7]

© Cambridge International Examinations 2015


173
Page 6 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 42

(b) (i) Mark as follows (parts to be ignored in grey):

If no programming language stated, map to 1 of the 3 below (or check in Q1ai)


Class header & ending (watch out these may be squashed into the next clip)
Ignore methods
2 attributes with correct data types
No mark if subclass properties shown here
Attributes required:
StudentName
DateOfBirth (accept variations e.g. DoB)

Pascal

TYPE Student = CLASS


PUBLIC
Procedure ShowStudentName();
Procedure ShowDateOfBirth();
PRIVATE
StudentName : STRING;
DateOfBirth : TDateTime; // accept string reject Date
END;

Python
class Student :
def __int__(self) :
self.__StudentName = ""
self.__DateOfBirth = "" # date(1,1,2015)
def ShowStudentName() :
pass
def ShowDateOfBirth() :
pass

Ignore __ before attributes

VB.NET
Class Student
Public Sub ShowStudentName()
End Sub
Public Sub ShowDateOfBirth()
End Sub
Private StudentName As String
Private DateOfBirth As Date ‘ accept string
End Class

(Ignore: must inherit)


Ignore Private/protected/public
Don’t give a mark if using DIM [2]

© Cambridge International Examinations 2015


174
Page 7 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 42

(ii) Mark as follows:

– Class header and showing superclass


– Properties (Do not award this mark if properties from base class included here)
Data types must be correct
– Methods (Do not award this mark if methods from base class included here)
must show heading and ending of procedure/function declaration
Ignore PUBLIC, PRIVATE

Pascal
TYPE FullTimeStudent = CLASS (Student)
PUBLIC
Procedure ShowAddress();
Procedure ShowTelephoneNumber();
PRIVATE
Address : STRING;
TelephoneNumber : STRING; // reject integer
END;

Python
class FullTimeStudent(Student) :
def __init__(self) :
self.__Address = ""
self.__TelephoneNumber = ""
def ShowAddress() :
pass
def ShowTelephoneNumber() :
pass

VB.NET
Class FullTimeStudent : Inherits Student
Public Sub ShowAddress()
End Sub
Public Sub ShowTelephoneNumber()
End Sub
Private Address As String
Private TelephoneNumber As String ‘ reject integer
End Class

No mark if using DIM [3]

© Cambridge International Examinations 2015


175
Page 8 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 42

(iii) 1 mark per statement to max 3


Missing string delimiters: penalise once
Accept use of constructor

Pascal
NewStudent := FullTimeStudent.Create;
NewStudent.StudentName := 'A.Nyone';
NewStudent.DateOfBirth := EncodeDate(1990, 11,12);//:=
‘11/12/1990’
NewStudent.TelephoneNumber := '099111';

Alternative
NewStudent := FullTimeStudent.Create(‘A.Nyone’, ‘12/11/1990’,
‘099111’);

Python
NewStudent = FullTimeStudent()
NewStudent.StudentName = "A.Nyone"
NewStudent.DateOfBirth = "12/11/1990"
NewStudent.TelephoneNumber = "099111"

Alternative
NewStudent = FullTimeStudent(‘A.Nyone’, ‘12/11/1990’, ‘099111’)

VB.NET
Dim NewStudent As FullTimeStudent = New FullTimeStudent()
NewStudent.StudentName = "A.Nyone"
NewStudent.DateOfBirth = #11/12/1990#
NewStudent.TelephoneNumber = "099111"

Alternative
Dim NewStudent As FullTimeStudent = New
FullTimeStudent(“A.Nyone”, “12/11/1990”, “099111”)
[Max 3]

© Cambridge International Examinations 2015


176
Page 9 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 42

4 (a) FUNCTION Hash(Key : STRING) RETURNS INTEGER


DECLARE Number : INTEGER
Number  ASCII(LEFTSTRING(Key,1))
// Number  ASCII(Key[1])
Number  Number – 64
RETURN Number
// Result  Number // Hash  Number
ENDFUNCTION

Accept ASC instead of ASCII


Accept LEFT instead of LEFTSTRING
Key can be a different identifier but must be the same in both places [5]

(b) (i)
Dictionary
Index Key Value
1
2
3 Computer Rechner

4 Disk Platte
5 Error Fehler
6 File Datei
7
8
: :
: :
1999
2000

Ignore spelling mistakes


1 mark for 2 correct pairs entered in correct slots [2]

(ii) Collision / synonym / space already occupied / same index in array


Overwrites previous key-value pair

reject error [Max 2]

(iii) Create an overflow area


The 'home' record has a pointer to others with the same key // linked list
OR
Store the overflow record at the next available address …
in sequence (= next available)
OR
Re-design the hash function …. // write a different/another algorithm
to generate a wider range of indexes // enlarging storage space // to create fewer
collisions [2]

© Cambridge International Examinations 2015


177
Page 10 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 42

(iv) Mark as follows:

Check whether slot is empty:


IF Dictionary[Index,1] <>”” // != ‘’ // > NULL // >
NONE
If not: update index: THEN Index  <some value>
…to find an empty slot (loop / follow pointer / go to overflow area) reject FOR loop
Insert code between lines 20 and 30

21 WHILE Dictionary[Index,1] > ""


22 Index  Index + 1
23 IF Index > 2000
24 THEN
25 Index  1
26 ENDIF
27 ENDWHILE [4]

5 (a) (i)
Memory Address
Accumulator 509 510 511 512
0 7 3 0 0
7 7
0
1 1
7
14 14
1
2 2
14
21 21
2
3 3

3 marks 1 mark 1 mark

If values changed in column 509 or 510 don’t give marks for 511/512 [5]

(ii) stores the counter value for ….// acts as a control variable/counter
How many times the loop has been performed // control the loop

Ignore re-stating the steps [2]

(b) LDM #12 (must be instruction before storage)


STO 509 (must be final instruction)

1 mark for each instruction [2]

© Cambridge International Examinations 2015


178
Page 11 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 42

6 (a) 1 mark for structure header/ending


1 mark for each field correct, take away 1 mark for additional fields
Python answers will use a class

Pascal
TYPE StockItem = RECORD
ProductCode : String; // accept integer
Price : Currency; // accept real
NumberInStock : Integer;
END;

Python
class StockItem :
def __init__(self) :
self.ProductCode = "" # = 0
self.Price = 0.0 # = 0
self.NumberInStock = 0

VB.NET
STRUCTURE StockItem
Dim ProductCode As String ‘ accept integer
Dim Price As Decimal ‘ Double/single
Dim NumberInStock As Integer
END STRUCTURE

VB6
Type StockItem
ProductCode As String ‘ accept integer
Price As Currency ‘ Double/single
NumberInStock As Integer
END Type [4]

© Cambridge International Examinations 2015


179
Page 12 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 42

(b) (i) 01 TRY


02 OPENFILE "StockFile" FOR READ/RANDOM // ignore “
03 EXCEPT
04 OUTPUT "File does not exist"
05 ENDTRY [2]

(ii) (Line 01) alerts system to check for possible run-time errors (exception)
(Lines 03, 04) handle the exception without the program crashing // keeps program
running// provide alternative statements to execute to avoid run-time error

Accept “exception handling” for 1 mark [Max 2]

(c) WHILE NOT EOF("StockFile")


READFILE "StockFile", ThisStockItem // accept reading separate
fields
OUTPUT ThisStockItem.ProductCode
OUTPUT ThisStockItem.NumberInStock
ENDWHILE

1 mark for loop (accept REPEAT)


1 mark for EOF(“StockFile”) // StockFile.Peek <> -1 / NONE/’’
1 mark for READ record
1 mark for OUTPUT of 2 fields

Ignore opening and closing file [4]

© Cambridge International Examinations 2015


180

Cambridge International Examinations


Cambridge International Advanced Level

COMPUTER SCIENCE 9608/43


Paper 4 Further Problem-solving and Programming Skills October/November 2015
PRE-RELEASE MATERIAL
* 7 2 1 3 6 9 6 1 0 8 *

This material should be given to candidates on receipt by the Centre.

READ THESE INSTRUCTIONS FIRST

Candidates should use this material in preparation for the examination. Candidates should attempt the
practical programming tasks using their chosen high-level, procedural programming language.

This document consists of 9 printed pages and 3 blank pages.

DC (NH/SW) 111426
© UCLES 2015 [Turn over
181
2

This material is intended to be read by teachers and candidates prior to the November 2015 examination
for 9608 Paper 4.

Reminders
The syllabus states:
• there will be questions on the examination paper which do not relate to this pre-release
material
• you must choose a high-level programming language from this list:
ͦ Visual Basic (console mode)
ͦ Python
ͦ Pascal / Delphi (console mode)

The practical skills covered in Paper 2 are a precursor to those required in Paper 4. It is therefore
recommended that the high-level programming language chosen for this paper is the same as that for
Paper 2. This allows for sufficient expertise to be acquired with the opportunity for extensive practice.

Questions on the examination paper may ask the candidate to write:


• structured English
• pseudocode
• program code

A program flowchart should be considered as an alternative to pseudocode for the documenting of an


algorithm design.

Candidates should be confident with:


• the presentation of an algorithm using either a program flowchart or pseudocode
• the production of a program flowchart from given pseudocode or the reverse

© UCLES 2015 9608/43/PRE/O/N/15


182
3

TASK 1

The taxis used by a taxi company are either cars or minibuses.

The unique registration and the charge (in $) per unit time are stored for all taxis.

All cars can carry a maximum of four passengers.

Data stored about minibuses also includes an extra charge (in $) per booking and the maximum
number of passengers allowed.

The company needs software to process data about taxis.

The processing needs to include a calculation of the fare charged.

The software will be object-oriented.

The superclass (also known as base class or parent class) Taxi is designed.

Two subclasses (also known as derived classes or child classes) have been identified:

• Car
• Minibus
Key focus: Object-oriented Programming
TASK 1.1
Complete the inheritance diagram.

© UCLES 2015 9608/43/PRE/O/N/15 [Turn over


183
4

TASK 1.2
Complete the class diagram showing the appropriate properties and methods.

.......................................................................

.......................................................................

.......................................................................

.......................................................................

.......................................................................

.......................................................................

.......................................................................

....................................................................... .......................................................................

....................................................................... .......................................................................

....................................................................... .......................................................................

....................................................................... .......................................................................

Constructor() .......................................................................

....................................................................... .......................................................................

....................................................................... .......................................................................

....................................................................... .......................................................................

Note: a constructor is a method that creates a new instance of a class and initialises it.

TASK 1.3
Write program code for the class definitions. Make use of polymorphism and inheritance where
appropriate.

TASK 1.4
Write program code to create a new instance of Car.

Suggested extension task


Write program code to display the properties of the object you created in Task 1.4.

© UCLES 2015 9608/43/PRE/O/N/15


184
5

TASK 2

Key focus: Project management using


PERT and GANTT charts
A software program is to be written for a client.

A detailed program specification has been written. The program will consist of seven different menu
options handled from a main module by calling seven different procedures. These modules can be
coded independently.

All procedures and the main module are each estimated to take 3 hours to code and 2 hours to test.

Integration testing is expected to take 3 hours and Alpha testing 7 hours.

TASK 2.1
The project manager initially has one programmer available to write and test the program. The
programmer works 10 hours a day. Calculate how many days it takes before the customer can start
acceptance testing.

TASK 2.2
The customer is not happy about the proposed development time and the project manager considers
hiring extra staff.

One proposal is to deploy one programmer and one software tester to the project.

The project manager needs a PERT chart to calculate the critical path.

Complete the diagram below.

1 3 4 5

2
Key focus: Project management
using a PERT chart

Note: the arrow denotes a dummy activity.

Write the critical path.

Calculate the shortest time (in days) before the client can start acceptance testing.

© UCLES 2015 9608/43/PRE/O/N/15 [Turn over


185
6

TASK 2.3
Another proposal is to deploy four programmers, who each carry out their own module testing.

TASK 2.3.1
Draw a GANTT chart for this proposal.
Key focus: Project management using
a GANTT chart

Activity

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Hour number
1
2
3
4
5
6
7
8
9

TASK 2.3.2
If the programmers each work 10 hours a day, calculate how many days it takes before the customer
can start acceptance testing.

Suggested extension task


Try other proposals, such as only a software tester can carry out any testing.
Activity
Code P1
Test P1
Code P2
Test P2
Code P3
Test P3
Code P4
Test P4
Code P5
Test P5
Code P6
Test P6
Code P7
Test P7
Code P8
Test P8
Integration testing
Alpha testing
Hour number
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
1
2
3
4
5
6
7
8
9

© UCLES 2015 9608/43/PRE/O/N/15


186
7

TASK 3

Data about books are stored in a random file of records.

• The key field of a book record is the ISBN (a 9-digit string and a check digit).
• Other book data are stored.
• A hashing function is used to calculate a record address.
(The first 3 digits of the ISBN are used as the record address.)
• The random file initially consists of dummy records.
• Dummy records are shown by the ISBN set to 0000000000.

FUNCTION Hash(ISBN : STRING) RETURNS INTEGER


Address ← LeftToInt(ISBN, 3)
RETURN Address Key focus: Random files
ENDFUNCTION

The Hash function assumes the existence of the function LeftToInt, defined below:

LeftToInt(ThisString : STRING, n: INTEGER) RETURNS INTEGER


returns an integer calculated from the n-digit string, starting from the left of the string ThisString.

An error is returned if:


- any of the first n characters of ThisString are non-digit characters
- the length of ThisString is less than n

For example: LeftToInt("1575697620", 3) returns the integer 157

Note: Random files are also known as direct access files.

TASK 3.1
Write program code to implement the functions LeftToInt and Hash.

© UCLES 2015 9608/43/PRE/O/N/15 [Turn over


187
8

TASK 3.2
Write program code to implement the following pseudocode which initialises a random file:

TYPE BookRecord
DECLARE ISBN : STRING[10] // need fixed-length records for
DECLARE Title : STRING[24] // random files
DECLARE OnLoan : BOOLEAN
ENDTYPE

DECLARE DummyRecord : BookRecord

DummyRecord.ISBN ← "0000000000"

OPENFILE "BookFile" FOR WRITE // create the file by sequentially


// writing dummy records to the new file
// prior to use as a random file
FOR Count ← 1 TO 1000
PUTRECORD "BookFile", DummyRecord
ENDFOR
CLOSEFILE "BookFile"

TASK 3.3
Write program code to implement the following pseudocode to input 5 book records:

010 DECLARE NewBook : BookRecord


020
030 OPENFILE "BookFile" FOR RANDOM
040 FOR Count ← 1 TO 5
050 INPUT NewBook.ISBN
060 INPUT NewBook.Title
070 NewAddress ← Hash(NewBook.ISBN)
080 SEEK "BookFile", NewAddress
090 PUTRECORD "BookFile", NewBook
100 ENDFOR
110 CLOSEFILE "BookFile"

Test your program by inputting book details with ISBNs that will hash to different addresses.

TASK 3.4
You need to test that the records have been saved successfully.

Write program code to read records sequentially from the random file BookFile and output any non-
zero records.
© UCLES 2015 9608/43/PRE/O/N/15
188
9

TASK 3.5
Key focus: Exception handling

If a program tries to open a non-existent file, a run-time error will occur.

To avoid this, you need to write exception handling code to give an error message instead.

Edit your program code from Task 3.3 to handle the case when "BookFile" does not exist.

TASK 3.6
Add a book record with an ISBN that will cause a collision (also known as a synonym).

Run your program from Task 3.4 again. What do you notice?

TASK 3.7
The pseudocode in Task 3.3 needs amending to handle a collision.

The following algorithm needs to be inserted between line 080 and 090.

Write pseudocode for the following structured English algorithm:

Repeat until useable address found, or file is full:


If there is a record with a non-zero ISBN at the address hashed
Go to the next record address
If the end of the file is reached, start at the beginning of the file
If the hashed address is reached again, the file is full

Write program code for your algorithm and test it.

Suggested extension task


Write program code to extend your program from Task 3.5 so your program will successfully add and
delete book records, even if their ISBNs cause collisions.

© UCLES 2015 9608/43/PRE/O/N/15


189

Cambridge International Examinations


Cambridge International Advanced Level
* 4 0 9 5 2 0 9 1 3 2 *

COMPUTER SCIENCE 9608/43


Paper 4 Further Problem-solving and Programming Skills October/November 2015
2 hours
Candidates answer on the Question Paper.
No Additional Materials are required.
No calculators allowed.

READ THESE INSTRUCTIONS FIRST

Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.

Answer all questions.


No marks will be awarded for using brand names of software packages or hardware.

At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.

The maximum number of marks is 75.

This document consists of 16 printed pages.

DC (KN/SW) 115643
© UCLES 2015 [Turn over
190
2

Throughout the paper you will be asked to write either pseudocode or program code.

Complete the statement to indicate which high-level programming language you will use.

Programming language ...........................................................................................................................

1 A large software house has been asked to supply a computerised solution for a business. The
project manager has drawn up a list of activities and their likely duration.

Weeks to
Activity Description
complete
A Write requirement specification 5
B Produce program design 5
C Write module code 15
D Module testing 10
E Integration testing 5
F Alpha testing 3
G Install software and acceptance testing 5
H Write end user training guide 5
J Write technical documentation 10
K End user training 4
L Sign off final system 1

(a) The project manager decides to construct a Program Evaluation Review Technique (PERT)
chart from this data.

1 5 2 3 5 6 3 7 9
A F
10
J
4 8

10

(i) Complete the PERT chart. [7]

(ii) State the critical path.

.......................................................................................................................................[2]

(iii) Calculate the minimum number of weeks for the completion of this solution.

.......................................................................................................................................[1]

© UCLES 2015 9608/43/O/N/15


191
3

(b) For activity J:

(i) State the earliest start time.

Week number ................................................................................................................[1]

(ii) State the latest start time.

Week number ................................................................................................................[1]

(c) Give a reason why the project manager used a PERT chart.

...................................................................................................................................................

...............................................................................................................................................[1]

© UCLES 2015 9608/43/O/N/15 [Turn over


192
4

2 A declarative programming language is used to represent the following facts and rules:

01 male(ali).
02 male(raul).
03 male(ahmed).
04 male(philippe).
05 female(meena).
06 female(aisha).
07 female(gina).
08 parent(ali, raul).
09 parent(meena, raul).
10 parent(ali, ahmed).
11 parent(meena, ahmed).
12 parent(ali, aisha).
13 parent(meena, aisha).
14 father(A, B) IF male(A) AND parent(A, B).

These clauses have the following meaning:

Clause Explanation
01 Ali is male
05 Meena is female
08 Ali is a parent of Raul
14 A is the father of B if A is male and A is a parent of B

(a) More facts are to be included.

Philippe and Gina are the parents of Meena.

Write the additional clauses to record this.

15 ..........................................................................................................................................

16 ......................................................................................................................................[2]

(b) Using the variable P, the goal

parent(P, raul)

returns

P = ali, meena

Write the result returned by the goal

parent(ali, C)

C = ......................................................................................................................................[2]

© UCLES 2015 9608/43/O/N/15


193
5

(c) Use the variable F to write the goal to find the father of Ahmed.

...............................................................................................................................................[1]

(d) Write the rule to show that X is the mother of Y.

mother(X, Y)

IF .............................................................................................................................................

.............................................................................................................................................. [2]

(e) W is a grandparent of Z if W is a parent of one of Z’s parents.


Complete the following rule:

grandparent(W, Z)

IF .............................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(f) Complete the rule to show that G is a grandfather of K.

grandfather(G, K)

IF .............................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

© UCLES 2015 9608/43/O/N/15 [Turn over


194
6

3 A lending library stocks two types of item for loan: books and CDs.

All stock items have a title, the date the item was acquired and whether the item is currently out on
loan.

Books have an author and ISBN. CDs have an artist and play time in minutes.

The library needs a program to process data about the stock items. The program will use an
object-oriented programming language.

(a) Complete the class diagram showing the appropriate properties and methods.

StockItem

Title: STRING

......................................................................

......................................................................

......................................................................

ShowTitle()

......................................................................

......................................................................

......................................................................

Book CD

Author: STRING ......................................................................

...................................................................... ......................................................................

...................................................................... ......................................................................

...................................................................... ......................................................................

Constructor() ......................................................................

ShowAuthor() ......................................................................

...................................................................... ......................................................................

...................................................................... ......................................................................

[7]

© UCLES 2015 9608/43/O/N/15


195
7

(b) Write program code

(i) for the class definition for the superclass StockItem.

Programming language .....................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

(ii) for the class definition for the subclass Book.

Programming language .....................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

© UCLES 2015 9608/43/O/N/15 [Turn over


196
8

(iii) to create a new instance of Book with:


• identifier NewBook
• title “Computers”
• author A.Nyone
• ISBN 099111
• acquired on 12/11/2001
• not out on loan

Programming language .....................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

© UCLES 2015 9608/43/O/N/15


197
9

Question 4 begins on page 10.

© UCLES 2015 9608/43/O/N/15 [Turn over


198
10

4 A binary tree Abstract Data Type (ADT) has these associated operations:

• create the tree (CreateTree)


• add an item to tree (Add)
• output items in ascending order (TraverseTree)

(a) Show the final state of the binary tree after the following operations are carried out.

CreateTree
Add("Dodi")
Add("Farai")
Add("Elli")
Add("George")
Add("Ben")
Add("Celine")
Add("Ali")

[4]

© UCLES 2015 9608/43/O/N/15


199
11

(b) The binary tree ADT is to be implemented as an array of nodes. Each node consists of data
and two pointers.

Using pseudocode, a record type, Node, is declared as follows:

TYPE Node
DECLARE Name : STRING
DECLARE LeftPointer : INTEGER
DECLARE RightPointer : INTEGER
ENDTYPE

The statement

DECLARE Tree : ARRAY[1:10] OF Node

reserves space for 10 nodes in array Tree.

The CreateTree operation links all nodes into a linked list of free nodes. It also initialises the
RootPointer and FreePointer.

Show the contents of the Tree array and the values of the two pointers, RootPointer and
FreePointer, after the operations given in part (a) have been carried out.

Tree
RootPointer Name LeftPointer RightPointer
[1]

[2]

FreePointer [3]

[4]

[5]

[6]

[7]

[8]

[9]

[10]
[7]

© UCLES 2015 9608/43/O/N/15 [Turn over


200
12

(c) A programmer needs an algorithm for outputting items in ascending order. To design this, the
programmer writes a recursive procedure in pseudocode.

(i) Complete the pseudocode:

01 PROCEDURE TraverseTree(BYVALUE Root: INTEGER)

02 IF Tree[Root].LeftPointer .................................................................

03 THEN

04 TraverseTree( .............................................................................)

05 ENDIF

06 OUTPUT .............................................................................................. .Name

07 IF ........................................................................................................ <> 0

08 THEN

09 TraverseTree( .............................................................................)

10 ENDIF

11 ENDPROCEDURE
[5]

(ii) Explain what is meant by a recursive procedure. Give a line number from the code above
that shows procedure TraverseTree is recursive.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

Line number ..................................................................................................................[2]

(iii) Write the pseudocode call required to output all names stored in Tree.

...........................................................................................................................................

.......................................................................................................................................[1]

© UCLES 2015 9608/43/O/N/15


201
13

Question 5 begins on page 14.

© UCLES 2015 9608/43/O/N/15 [Turn over


202
14

5 Data about sports club members are stored in a random file of records.

• The key field of a member record is the member ID (range 1000 to 9999).
• Other member data are stored.
• A hashing function is used to calculate a record address.
• The random file initially consists of dummy records.
• Dummy records are shown by member ID set to 0.

FUNCTION Hash(MemberID : INTEGER) RETURNS INTEGER

Address ← MemberID MOD 100

RETURN Address

ENDFUNCTION

(a) New members with the following member IDs have joined the sports club:

1001, 3005, 4096, 2098, 7002

Indicate where each record should be stored by deleting the zero and writing the member ID
in the correct cell.

MembershipFile
Address MemberID Other member data

0 0

1 0

2 0

3 0

4 0

5 0

6 0

7 0

8 0

96 0

97 0

98 0

99 0 [2]

© UCLES 2015 9608/43/O/N/15


203
15

(b) (i) The program stores a new member’s data in the record variable NewMember. The field
MemberID stores the member ID.

Complete the pseudocode:

10 // generate record address

20 NewAddress ← ..........................................................................................................

30 // move pointer to the disk address for the record

40 SEEK ...........................................................................................................................

50 PUTRECORD "MembershipFile", ..........................................................................


[4]

(ii) Before records can be saved to the file MembershipFile, the file needs to be opened.

Complete the pseudocode.

01 TRY

02 OPENFILE ..................................................................................... FOR RANDOM

03 EXCEPT

04 ..............................................................................................................................

05 ENDTRY
[2]

(iii) A record with member ID 9001 is to be stored.

Explain the problem that occurs when this record is saved.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(iv) Describe a method, without changing the function Hash, to handle the problem identified
in part (b)(iii).

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

© UCLES 2015 9608/43/O/N/15 [Turn over


204
16

(v) Write pseudocode to implement the method you described in part (b)(iv).

Choose line numbers to indicate where your pseudocode should be inserted in the
pseudocode of part (b)(i).

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[4]

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 International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.

Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.

© UCLES 2015 9608/43/O/N/15


205

CAMBRIDGE INTERNATIONAL EXAMINATIONS


Cambridge International Advanced Level

MARK SCHEME for the October/November 2015 series

9608 COMPUTER SCIENCE


9608/43 Paper 4 (Written Paper), maximum raw mark 75

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of
the examination. It shows the basis on which Examiners were instructed to award marks. It does not
indicate the details of the discussions that took place at an Examiners’ meeting before marking began,
which would have considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner
Report for Teachers.

Cambridge will not enter into discussions about these mark schemes.

Cambridge is publishing the mark schemes for the October/November 2015 series for most
Cambridge IGCSE®, Cambridge International A and AS Level components and some
Cambridge O Level components.

® IGCSE is the registered trademark of Cambridge International Examinations.


206
Page 2 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 43

1 (a) (i)

5 5 15 5 3 5
A B C E F G

[max. 7]

(ii) 1 – 2 – 3 – 5 – 6 – 7 – 9 – 8 – 10
1–5 scores 1
6–10 scores 1 [2]

(iii) 43 weeks [1]

(b) (i) week number 25 [1]

(ii) week number 32 [1]

(c) To see what activities can be done in parallel // show dependencies


To record changes to project timings [max. 1]

© Cambridge International Examinations 2015


207
Page 3 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 43

2 (a) parent(philippe, meena).


parent(gina, meena). [2]

(b) ahmed, aisha, raul [2]

(c) father(F, ahmed). [1]

(d) mother(X, Y)
IF
female(X) AND parent(X, Y). [2]

(e) grandparent(W, Z)
IF
parent(W,X)
AND parent(X,Z). [2]

(f) grandfather(G, K)
IF
male(G) AND
grandparent(G, K).

alternative:

father(G, X) AND
parent(X, K). [2]

© Cambridge International Examinations 2015


208
Page 4 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 43

3 (a)
StockItem
Title: STRING
DateAcquired : TDATETIME………………………
OnLoan: BOOLEAN .………………………………………
………………………………………………………………………………………

ShowTitle()
ShowDateAcquired() ……………………………………
ShowOnLoan() …………………………………………………
………………………………………………………………………………………

Book CD
Author: STRING Artist: STRING ……………………………………………
ISBN: STRING………………………………………… Playtime: INTEGER ……………………………………
……………………………………………………………………………………… ………………………………………………………………………………………
……………………………………………………………………………………… ………………………………………………………………………………………

Constructor() Constructor()…………………………………………………
ShowAuthor() ShowArtist() …………………………………………………
ShowISBN()………………………………………………………… ShowPlayTime() ……………………………………………
……………………………………………………………………………………… ………………………………………………………………………………………

[max. 7]

© Cambridge International Examinations 2015


209
Page 5 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 43

(b) (i) Mark as follows:


Class header
Methods
Properties

Pascal

StockItem = CLASS
PUBLIC
Procedure ShowTitle();
Procedure ShowDateAcquired();
Procedure ShowOnLoan();
PRIVATE
Title : STRING;
DateAcquired : TDateTime;
OnLoan : Boolean;
END;

Python

class StockItem :
def __int__(self) :
self.__Title = ""
self.__DateAquired = ""
self.__OnLoan = False

def ShowTitle() :
pass
def ShowDateAcquired() :
pass
def ShowOnLoan() :
pass

VB.NET

Class StockItem
Public Sub ShowTitle()
End Sub
Public Sub ShowDateAquired()
End Sub
Public Sub ShowOnLoan()
End Sub
Private Title As String
Private DateAquired As Date
End Class [3]

© Cambridge International Examinations 2015


210
Page 6 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 43

(ii) Mark as follows:


Class header and showing superclass
Methods
Properties

Pascal

TYPE Book = CLASS (StockItem)


PUBLIC
Procedure ShowAuthor();
Procedure ShowISBN();
PRIVATE
Author : STRING;
ISBN : STRING;
END;

Python

class Book(StockItem) :
def __init__(self) :
self.__Author = ""
self.__ISBN = ""
def ShowAuthor() :
pass
def ShowISBN() :
pass

VB.NET

Class Book : Inherits StockItem


Public Sub ShowAuthor()
End Sub
Public Sub ShowISBN()
End Sub
Private Author As String
Private ISBN As String ‘ reject integer
End Class [3]

© Cambridge International Examinations 2015


211
Page 7 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 43

(iii) Pascal

NewBook := Book.Create; 1
NewBook.Title := 'Computers';
NewBook.Author := 'A.Nyone';
NewBook.ISBN := '099111'; 1
NewBook.DateAcquired := '12/11/2001';
NewBook.OnLoan := FALSE 1

Python

NewBook = Book() 1
NewBook.Title = "Computers"
NewBook.Author = "A.Nyone"
NewBook.ISBN = "099111" 1
NewBook.DateAcquired = "12/11/2001"
NewBook.OnLoan = False 1

VB.NET

Dim NewBook As Book = New Book() 1


NewBook.Title = "Computers"
NewBook.Author = "A.Nyone"
NewBook.ISBN = "099111" 1
NewBook.DateAcquired = #12/11/2001#
NewBook.OnLoan = False 1 [3]

© Cambridge International Examinations 2015


212
Page 8 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 43

4 (a)

[4]

(b)
Tree

RootPointer Name LeftPointer RightPointer


1 [1] Dodi 5 2

[2] Farai 3 4

FreePointer [3] Elli 0 0


8 [4] George 0 0

[5] Ben 7 6

[6] Celine 0 0

[7] Ali 0 0

[8] 9 0

[9] 10 0

[10] 0 0
[7]

© Cambridge International Examinations 2015


213
Page 9 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 43

(c) (i) 01 PROCEDURE TraverseTree(BYVALUE Root : INTEGER)


02 IF Tree[Root].LeftPointer < > 0
03 THEN
04 TraverseTree(Tree[Root].LeftPointer)
05 ENDIF
06 OUTPUT Tree[Root].Name
07 IF Tree[Root].RightPointer < > 0
08 THEN
09 TraverseTree(Tree[Root].RightPointer)
10 ENDIF
11 ENDPROCEDURE [5]

(ii) A procedure that calls itself // is defined in terms of itself


Line number: 04/09 [2]

(iii) TraverseTree(RootPointer) [1]

5 (a)
MembershipFile

Address MemberID other member data

0 0

1 1001

2 7002

3 0

4 0

5 3005

6 0

7 0

8 0

: :

: :

96 4096

97 0

98 2098

99 0

1001 and 7002 and 3005 1


4096 and 2098 1 [2]

© Cambridge International Examinations 2015


214
Page 10 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2015 9608 43

(b) (i) 10 // generate record address


20 NewAddress  Hash(NewMember.MemberID)
30 // move pointer to the disk address for the record
40 SEEK NewAddress
50 PUTRECORD "MembershipFile", NewMember [4]

(ii) 01 TRY
02 OPENFILE "MembershipFile" FOR RANDOM
03 EXCEPT
04 OUTPUT "File does not exist"
05 ENDTRY [2]

(iii) collisions/synonyms
The previous record will be overwritten [2]

(iv) Create an overflow area


The ‘home’ record has a pointer to others with the same key
OR
Store the overflow record at the next available address
in sequence
OR
Re-design the hash function ….
to generate a wider range of indexes // to create fewer collisions [2]

(v) 41 GETRECORD "MembershipFile", CurrentRecord


42 WHILE CurrentRecord.MemberID <> 0
43 NewAddress  NewAdress + 1
44 IF NewAddress > 99 THEN NewAddress  0
45 SEEK NewAddress
46 GETRECORD "MembershipFile", CurrentRecord
47 ENDWHILE [max. 4]

© Cambridge International Examinations 2015


215

Cambridge International Examinations


Cambridge International Advanced Level
* 6 9 4 8 8 4 1 8 3 2 *

COMPUTER SCIENCE 9608/32


Paper 3 Advanced Theory May/June 2016
1 hour 30 minutes
Candidates answer on the Question Paper.
No Additional Materials are required.
No calculators allowed.

READ THESE INSTRUCTIONS FIRST

Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.

Answer all questions.


No marks will be awarded for using brand names of software packages or hardware.

At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.

The maximum number of marks is 75.

This document consists of 15 printed pages and 1 blank page.

DC (ST/AR) 126657
© UCLES 2016 [Turn over
216
2

1 A Local Area Network (LAN) consists of four computers and one server. The LAN uses a bus
topology.

(a) Complete the diagram below to show how the computers and the File server could be
connected.

Computer
A

Computer File server Computer


D B

Computer
C
[2]

(b) Computer C sends a data packet to Computer A.

Three statements are given below.

Tick (✓) to show whether each statement is true or false.

Statement True False


Computer C uses the IP address of Computer A
to indicate that the packet is for Computer A.
Computer B can read the packet sent from
Computer C to Computer A.
The File server routes the packet to Computer A.
[3]

© UCLES 2016 9608/32/M/J/16


217
3

(c) Computer A starts transmitting a packet to Computer C. At exactly the same time, the File
server starts transmitting a packet to Computer D. This causes a problem.

(i) State the name given to this problem.

...........................................................................................................................................

.......................................................................................................................................[1]

(ii) Give three steps taken by both Computer A and the File server to allow them to transmit
their packets successfully.

Step 1 ................................................................................................................................

...........................................................................................................................................

Step 2 ................................................................................................................................

...........................................................................................................................................

Step 3 ................................................................................................................................

.......................................................................................................................................[3]

(d) Adding a switch to the LAN changes its topology. Explain how the use of a switch removes the
problem identified in part (c)(i).

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]

© UCLES 2016 9608/32/M/J/16 [Turn over


218
4

2 Digital certificates are used in Internet communications. A Certificate Authority (CA) is responsible
for issuing digital certificates.

(a) Name three data items present in a digital certificate.

1 ................................................................................................................................................

2 ................................................................................................................................................

3 ............................................................................................................................................[3]

(b) The method of issuing a digital certificate is as follows:

1 A user starts an application for a digital certificate using their computer. On this computer
a key pair is generated. This key pair consists of a public key and an associated private
key.

2 The user submits the application to the CA. The generated ........ (i) ........ key and
other application data are sent. The key and data are encrypted using
the CA’s ........ (ii) ........ key.

3 The CA creates a digital document containing all necessary data items and signs it using
the CA’s ........ (iii) ........ key.

4 The CA sends the digital certificate to the individual.

In the above method there are three missing words. Each missing word is either ‘public’ or
‘private’.

State the correct word. Justify your choice.

(i) ...........................................................................................................................................

Justification ........................................................................................................................

.......................................................................................................................................[2]

(ii) ...........................................................................................................................................

Justification ........................................................................................................................

.......................................................................................................................................[2]

(iii) ...........................................................................................................................................

Justification ........................................................................................................................

.......................................................................................................................................[2]

© UCLES 2016 9608/32/M/J/16


219
5

(c) Alexa sends an email to Beena.

Alexa’s email program:

• produces a message digest (hash)


• uses Alexa’s private key to encrypt the message digest
• adds the encrypted message digest to the plain text of her message
• encrypts the whole message with Beena’s public key
• sends the encrypted message with a copy of Alexa’s digital certificate

Beena’s email program decrypts the encrypted message using her private key.

(i) State the name given to the encrypted message digest.

.......................................................................................................................................[1]

(ii) Explain how Beena can be sure that she has received a message that is authentic (not
corrupted or tampered with) and that it came from Alexa.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(iii) Name two uses where encrypted message digests are advisable.

1 ........................................................................................................................................

2 ....................................................................................................................................[2]

© UCLES 2016 9608/32/M/J/16 [Turn over


220
6

3 (a) The following diagram shows how applications X, Y and Z can run on a virtual machine
system.

Application X Application Y Application Z

Guest operating
Guest operating system 1
system 2

Virtual machine software / virtual machine monitor

Host operating system

Hardware

(i) The virtual machine software undertakes many tasks.

Describe two of these tasks.

Task 1 ................................................................................................................................

...........................................................................................................................................

Task 2 ................................................................................................................................

.......................................................................................................................................[2]

(ii) Explain the difference between a guest operating system and a host operating
system.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

© UCLES 2016 9608/32/M/J/16


221
7

(b) A company uses a computer as a web server. The manufacturer will no longer support the
computer’s operating system (OS) in six months’ time. The company will then need to decide
on a replacement OS.

The company is also considering changing the web server software when the OS is changed.

Whenever any changes are made, it is important that the web server service is not disrupted.

In developing these changes, the company could use virtual machines.

(i) Describe two possible uses of virtual machines by the company.

Use 1 .................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

Use 2 .................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[4]

The web server often has to handle many simultaneous requests.

(ii) The company uses a virtual machine to test possible solutions to the changes that they
will need to make.

Explain one limitation of this approach.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

© UCLES 2016 9608/32/M/J/16 [Turn over


222
8

4 (a) Three file organisation methods and two file access methods are shown below.

Draw lines to link each file organisation method to its appropriate file access method or
methods.

File organisation method File access method

serial direct

sequential sequential

random

[4]

© UCLES 2016 9608/32/M/J/16


223
9

(b) A bank has a very large number of customers. The bank stores data for each customer. This
includes:

• unique customer number


• personal data (name, address, telephone number)
• transactions

The bank computer system makes use of three files:

• A – a file that stores customer personal data. This file is used at the end of each month
for the production of the monthly statement.
• B – a file that stores encrypted personal identification numbers (PINs) for customer bank
cards. This file is accessed when the customer attempts to withdraw cash at a cash
machine (ATM).
• C – a file that stores all customer transaction records for the current month. Every time
the customer makes a transaction, a new record is created.

For each of the files A, B and C, state an appropriate method of organisation. Justify your
choice.

(i) File A organisation ............................................................................................................

Justification ........................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

(ii) File B organisation ............................................................................................................

Justification ........................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

(iii) File C organisation ............................................................................................................

Justification ........................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

© UCLES 2016 9608/32/M/J/16 [Turn over


224
10

5 (a) Complete the truth table for this NAND gate:

A B X

A 0 0

X 0 1
B 1 0
1 1

[1]

A SR flip-flop is constructed using two NAND gates.

S
Q

Q
R

(b) (i) Complete the truth table for the SR flip-flop.


S R Q Q
Initially 1 0 0 1
R changed to 1 1 1
S changed to 0 0 1
S changed to 1 1 1
S and R changed to 0 0 0
[4]

(ii) One of the combinations in the truth table should not be allowed to occur.

State the values of S and R that should not be allowed. Justify your choice.

S = .............................. R = ..............................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]
© UCLES 2016 9608/32/M/J/16
225
11

Another type of flip-flop is the JK flip-flop.

(c) (i) Give one extra input present in the JK flip-flop.

...........................................................................................................................................

.......................................................................................................................................[1]

(ii) Give one advantage of the JK flip-flop.

...........................................................................................................................................

.......................................................................................................................................[1]

(d) Describe the role of flip-flops in a computer.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

© UCLES 2016 9608/32/M/J/16 [Turn over


226
12

6 An intruder detection system for a large house has four sensors. An 8-bit memory location stores
the output from each sensor in its own bit position.

The bit value for each sensor shows:

• 1 – the sensor has been triggered


• 0 – the sensor has not been triggered

The bit positions are used as follows:

Not used Sensor 4 Sensor 3 Sensor 2 Sensor 1

The output from the intruder detection system is a loud alarm.

(a) (i) State the name of the type of system to which intruder detection systems belong.

.......................................................................................................................................[1]

(ii) Justify your answer to part (i).

...........................................................................................................................................

.......................................................................................................................................[1]

(b) Name two sensors that could be used in this intruder detection system. Give a reason for
your choice.

Sensor 1 ...................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

Sensor 2 ...................................................................................................................................

Reason .....................................................................................................................................

...............................................................................................................................................[4]

© UCLES 2016 9608/32/M/J/16


227
13

The intruder system is set up so that the alarm will only sound if two or more sensors have been
triggered.
An assembly language program has been written to process the contents of the memory location.

The table shows part of the instruction set for the processor used.

Instruction
Explanation
Op code Operand
Direct addressing. Load the contents of the given address to
LDD <address>
ACC
STO <address> Store the contents of ACC at the given address
INC <register> Add 1 to the contents of the register (ACC or IX)
ADD <address> Add the contents of the given address to the contents of ACC
Bitwise AND operation of the contents of ACC with the
AND <address>
contents of <address>
CMP #n Compare the contents of ACC with the number n
JMP <address> Jump to the given address
Following a compare instruction, jump to <address> if the
JPE <address>
compare was True
Following a compare instruction, jump to <address> if the
JGT <address> content of ACC is greater than the number used in the
compare instruction
END End the program and return to the operating system

© UCLES 2016 9608/32/M/J/16 [Turn over


228
14

(c) Part of the assembly code is:

Op code Operand
SENSORS: B00001010
COUNT: 0
VALUE: 1
LOOP: LDD SENSORS
AND VALUE
CMP #0
JPE ZERO
LDD COUNT
INC ACC
STO COUNT
ZERO: LDD VALUE
CMP #8
JPE EXIT
ADD VALUE
STO VALUE
JMP LOOP
EXIT: LDD COUNT
TEST: CMP …
JGT ALARM

© UCLES 2016 9608/32/M/J/16


229
15

(i) Dry run the assembly language code. Start at LOOP and finish when EXIT is reached.

BITREG COUNT VALUE ACC


B00001010 0 1

[4]

(ii) The operand for the instruction labelled TEST is missing.

State the missing operand.

.......................................................................................................................................[1]

(iii) The intruder detection system is improved and now has eight sensors.

One instruction in the assembly language code will need to be amended.

Identify this instruction .......................................................................................................

Write the amended instruction ......................................................................................[2]

© UCLES 2016 9608/32/M/J/16


230

Cambridge International Examinations


Cambridge International Advanced Level

COMPUTER SCIENCE 9608/32


Paper 3 Written Paper May/June 2016
MARK SCHEME
Maximum Mark: 75

Published

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.

Cambridge will not enter into discussions about these mark schemes.

Cambridge is publishing the mark schemes for the May/June 2016 series for most Cambridge IGCSE®,
Cambridge International A and AS Level components and some Cambridge O Level components.

® IGCSE is the registered trademark of Cambridge International Examinations.

This document consists of 6 printed pages.

© UCLES 2016 [Turn over


231
Page 2 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2016 9608 32

Question Answer Marks

1 (a) Single line joining all four computers and file server 1
One “terminator” at each end 1

(b)
Statement True False
Computer C uses the IP address of  1
Computer A to indicate that the packet is
for Computer A.
Computer B can read the packet sent from  1
Computer C to Computer A.
The File server routes the packet to  1
Computer A.

(c) (i) Collision 1

(ii) Both stop transmitting 1


Each uses a random time 1
Wait for time period 1
Check for bus status 1
Attempt to re-transmit 1
Max 3

(d) Star topology created 1


A switch has a number of ports 1
Each connects to a single device (using a dedicated cable) 1
Switch provides direct transmission/path from device to device 1
Collisions are no longer possible 1
There are dedicated links from Computer A to Computer C AND from 1
the Server to Computer D
Max 4

2 (a) Examples:
Serial number A mark for
Certificate Authority that issued certificate each
CA digital signature correct
Name of company/organisation/individual/subject/owner owning data item –
Certificate
‘Subject’ public key
Period during which Certificate is valid // some relevant date Max 3

(b) (i) Public 1


The individual keeps their private key private // the public key can be
known by others (the public) 1

(ii) Public 1
The individual does not know the private key of the CA // the individual
only knows the public key of the CA // only the CA can decrypt the
packaged information 1

© Cambridge International Examinations 2016


232
Page 3 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2016 9608 32

(iii) Private 1
‘Only’ the CA’s public key will allow decryption of the Certificate //
proving the certificate was issued by the CA 1

(c) (i) Digital signature 1

(ii) Alexa’s digital certificate 1


(Includes) Alexa’s public key 1
Used to hash message received // produce message digest 1
Generated hash compared to digital signature 1
Max 2

(iii) Examples:
Financial transaction 1
Legal document 1
Software distribution 1
Max 2

3 (a) (i) Examples:


Create / delete virtual machine 1
Existing hardware made available to guest OS // hardware emulation 1
Ensures each virtual machine is protected from actions of another virtual 1
machine Max 2

(ii) Guest operating system:


An operating system running in a virtual machine //
Controls virtual hardware //
OS is being emulated 1

Host operating system:


The operating system that is actually controlling the physical hardware //
the operating system for the physical machine// the OS running the VM 1
software

Guest OS is running under the Host OS software 1


Max 2

(b) (i) Examples:


Trial/use alternative replacement operating system(s) … Two marks
Test to identify possible problems for each
Much easier to create VM with a new OS than create new computer use
system
Maximum
Trial/use alternative replacement web server software … two uses
Test to identify possible problems
Easier to try alternative new software and new OS combinations

To provide some additional service(s)


Trial/test its use - description e.g. a print server

General description point – to provide a safe environment during testing Max 4


(which does not disrupt the web server service)

© Cambridge International Examinations 2016


233
Page 4 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2016 9608 32

(ii) Examples:
Using virtual machine means execution of extra code // emulation of 1
some hardware …

Non-VM installation may not perform in the same way 1


Execution speed slower than non-VM system 1
Problems in judging actual response times 1
at time of maximum traffic needs fastest possible speed 1

Particular hardware may be difficult to emulate 1


Max 2

4 (a)
File organisation method File access method
1
serial direct

sequential sequential 2

random 1

(b) (i) Sequential 1


As all customers get statement … // high hit rate 1
Suitable for batch processing of the records // the records will be
processed one after the other 1
File organised using customer’s unique ID (as primary key field) 1
//
Serial 1
As all customers get statement … // high hit rate 1
Suitable for batch processing of the records // the records will be
processed one after the other 1
Order not important 1

Max 3

(ii) Random 1
Real-time transaction processing 1
Requires fastest access to data 1
No need to search through records 1

Max 3

© Cambridge International Examinations 2016


234
Page 5 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2016 9608 32

(iii) Serial 1
Each new record is appended 1
Transactions are recorded in chronological order 1
File re-organisation not required for each new record // no need for the
records to be sorted
Max 3

5 (a)
A B X
0 0 1
0 1 1
1
1 0 1
1 1 0

(b) (i)
S R Q Q
1 0 0 1
1
1 1 0 1 1

0 1 1 0 1
1
1 1 1 0

0 0 1 1

(ii) S=0R=0 1

Produces Q = 1 , Q =1 // Q and Q have same value 1


But Q and Q should be complements of each other 1
Becomes unstable 1

Max 3

(c) (i) Clock (pulse) 1

(ii) All four possibilities are valid 1


The 1-1 combination changes output to logical complement 1
Unstable state avoided 1
Invalid state cannot occur // the flip-flop is stable 1

Max 1

(d) Memory // data storage 1


Stores a single bit 1

6 (a) (i) Monitoring system 1

(ii) This is not a ‘feedback’ system //


There is no ‘control’ taking place/use of actuators //
No output other than from alarm 1

© Cambridge International Examinations 2016


235
Page 6 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2016 9608 32

(b) Examples:
Pressure … 1 – sensor
If intruder steps on sensor 1–
justification
Infra-red …
If beam cut by intruder Maximum
2 sensors
Motion / ultrasonic…
Detects any movement in an area

Contact / magnetic …
If door / window opened Max 4

(c) (i)
BITREG COUNT VALUE ACC Mark as
follows:
B00001010 0 1 B00001010
B00000000 1 mark for:
1
COUNT
2 2 column
B00001010
VALUE
B00000010 column
0
First two
1 1 values in
2 ACC
column
4 4
B00001010 Rest of
ACC
B00000000 column
4
8 8
B00001010
B00001000
1
2 2
8 Max 4

(ii) #1 1

(iii) CMP #8 1

CMP #128 1

© Cambridge International Examinations 2016


236

Cambridge International Examinations


Cambridge International Advanced Level
* 7 6 5 6 7 1 7 0 8 0 *

COMPUTER SCIENCE 9608/33


Paper 3 Advanced Theory May/June 2016
1 hour 30 minutes
Candidates answer on the Question Paper.
No Additional Materials are required.
No calculators allowed.

READ THESE INSTRUCTIONS FIRST

Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.

Answer all questions.


No marks will be awarded for using brand names of software packages or hardware.

At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.

The maximum number of marks is 75.

This document consists of 15 printed pages and 1 blank page.

DC (ST/AR) 126658
© UCLES 2016 [Turn over
237
2

1 A Local Area Network (LAN) consists of four computers and one server. The LAN uses a bus
topology.

(a) Complete the diagram below to show how the computers and the File server could be
connected.

Computer
A

Computer File server Computer


D B

Computer
C
[2]

(b) Computer C sends a data packet to Computer A.

Three statements are given below.

Tick (✓) to show whether each statement is true or false.

Statement True False


Computer C uses the IP address of Computer A
to indicate that the packet is for Computer A.
Computer B can read the packet sent from
Computer C to Computer A.
The File server routes the packet to Computer A.
[3]

© UCLES 2016 9608/33/M/J/16


238
3

(c) Computer A starts transmitting a packet to Computer C. At exactly the same time, the File
server starts transmitting a packet to Computer D. This causes a problem.

(i) State the name given to this problem.

...........................................................................................................................................

.......................................................................................................................................[1]

(ii) Give three steps taken by both Computer A and the File server to allow them to transmit
their packets successfully.

Step 1 ................................................................................................................................

...........................................................................................................................................

Step 2 ................................................................................................................................

...........................................................................................................................................

Step 3 ................................................................................................................................

.......................................................................................................................................[3]

(d) Adding a switch to the LAN changes its topology. Explain how the use of a switch removes the
problem identified in part (c)(i).

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]

© UCLES 2016 9608/33/M/J/16 [Turn over


239
4

2 Digital certificates are used in Internet communications. A Certificate Authority (CA) is responsible
for issuing digital certificates.

(a) Name three data items present in a digital certificate.

1 ................................................................................................................................................

2 ................................................................................................................................................

3 ............................................................................................................................................[3]

(b) The method of issuing a digital certificate is as follows:

1 A user starts an application for a digital certificate using their computer. On this computer
a key pair is generated. This key pair consists of a public key and an associated private
key.

2 The user submits the application to the CA. The generated ........ (i) ........ key and
other application data are sent. The key and data are encrypted using
the CA’s ........ (ii) ........ key.

3 The CA creates a digital document containing all necessary data items and signs it using
the CA’s ........ (iii) ........ key.

4 The CA sends the digital certificate to the individual.

In the above method there are three missing words. Each missing word is either ‘public’ or
‘private’.

State the correct word. Justify your choice.

(i) ...........................................................................................................................................

Justification ........................................................................................................................

.......................................................................................................................................[2]

(ii) ...........................................................................................................................................

Justification ........................................................................................................................

.......................................................................................................................................[2]

(iii) ...........................................................................................................................................

Justification ........................................................................................................................

.......................................................................................................................................[2]

© UCLES 2016 9608/33/M/J/16


240
5

(c) Alexa sends an email to Beena.

Alexa’s email program:

• produces a message digest (hash)


• uses Alexa’s private key to encrypt the message digest
• adds the encrypted message digest to the plain text of her message
• encrypts the whole message with Beena’s public key
• sends the encrypted message with a copy of Alexa’s digital certificate

Beena’s email program decrypts the encrypted message using her private key.

(i) State the name given to the encrypted message digest.

.......................................................................................................................................[1]

(ii) Explain how Beena can be sure that she has received a message that is authentic (not
corrupted or tampered with) and that it came from Alexa.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(iii) Name two uses where encrypted message digests are advisable.

1 ........................................................................................................................................

2 ....................................................................................................................................[2]

© UCLES 2016 9608/33/M/J/16 [Turn over


241
6

3 (a) The following diagram shows how applications X, Y and Z can run on a virtual machine
system.

Application X Application Y Application Z

Guest operating
Guest operating system 1
system 2

Virtual machine software / virtual machine monitor

Host operating system

Hardware

(i) The virtual machine software undertakes many tasks.

Describe two of these tasks.

Task 1 ................................................................................................................................

...........................................................................................................................................

Task 2 ................................................................................................................................

.......................................................................................................................................[2]

(ii) Explain the difference between a guest operating system and a host operating
system.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

© UCLES 2016 9608/33/M/J/16


242
7

(b) A company uses a computer as a web server. The manufacturer will no longer support the
computer’s operating system (OS) in six months’ time. The company will then need to decide
on a replacement OS.

The company is also considering changing the web server software when the OS is changed.

Whenever any changes are made, it is important that the web server service is not disrupted.

In developing these changes, the company could use virtual machines.

(i) Describe two possible uses of virtual machines by the company.

Use 1 .................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

Use 2 .................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[4]

The web server often has to handle many simultaneous requests.

(ii) The company uses a virtual machine to test possible solutions to the changes that they
will need to make.

Explain one limitation of this approach.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

© UCLES 2016 9608/33/M/J/16 [Turn over


243
8

4 (a) Three file organisation methods and two file access methods are shown below.

Draw lines to link each file organisation method to its appropriate file access method or
methods.

File organisation method File access method

serial direct

sequential sequential

random

[4]

© UCLES 2016 9608/33/M/J/16


244
9

(b) A bank has a very large number of customers. The bank stores data for each customer. This
includes:

• unique customer number


• personal data (name, address, telephone number)
• transactions

The bank computer system makes use of three files:

• A – a file that stores customer personal data. This file is used at the end of each month
for the production of the monthly statement.
• B – a file that stores encrypted personal identification numbers (PINs) for customer bank
cards. This file is accessed when the customer attempts to withdraw cash at a cash
machine (ATM).
• C – a file that stores all customer transaction records for the current month. Every time
the customer makes a transaction, a new record is created.

For each of the files A, B and C, state an appropriate method of organisation. Justify your
choice.

(i) File A organisation ............................................................................................................

Justification ........................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

(ii) File B organisation ............................................................................................................

Justification ........................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

(iii) File C organisation ............................................................................................................

Justification ........................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

© UCLES 2016 9608/33/M/J/16 [Turn over


245
10

5 (a) Complete the truth table for this NAND gate:

A B X

A 0 0

X 0 1
B 1 0
1 1

[1]

A SR flip-flop is constructed using two NAND gates.

S
Q

Q
R

(b) (i) Complete the truth table for the SR flip-flop.


S R Q Q
Initially 1 0 0 1
R changed to 1 1 1
S changed to 0 0 1
S changed to 1 1 1
S and R changed to 0 0 0
[4]

(ii) One of the combinations in the truth table should not be allowed to occur.

State the values of S and R that should not be allowed. Justify your choice.

S = .............................. R = ..............................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]
© UCLES 2016 9608/33/M/J/16
246
11

Another type of flip-flop is the JK flip-flop.

(c) (i) Give one extra input present in the JK flip-flop.

...........................................................................................................................................

.......................................................................................................................................[1]

(ii) Give one advantage of the JK flip-flop.

...........................................................................................................................................

.......................................................................................................................................[1]

(d) Describe the role of flip-flops in a computer.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

© UCLES 2016 9608/33/M/J/16 [Turn over


247
12

6 An intruder detection system for a large house has four sensors. An 8-bit memory location stores
the output from each sensor in its own bit position.

The bit value for each sensor shows:

• 1 – the sensor has been triggered


• 0 – the sensor has not been triggered

The bit positions are used as follows:

Not used Sensor 4 Sensor 3 Sensor 2 Sensor 1

The output from the intruder detection system is a loud alarm.

(a) (i) State the name of the type of system to which intruder detection systems belong.

.......................................................................................................................................[1]

(ii) Justify your answer to part (i).

...........................................................................................................................................

.......................................................................................................................................[1]

(b) Name two sensors that could be used in this intruder detection system. Give a reason for
your choice.

Sensor 1 ...................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

Sensor 2 ...................................................................................................................................

Reason .....................................................................................................................................

...............................................................................................................................................[4]

© UCLES 2016 9608/33/M/J/16


248
13

The intruder system is set up so that the alarm will only sound if two or more sensors have been
triggered.
An assembly language program has been written to process the contents of the memory location.

The table shows part of the instruction set for the processor used.

Instruction
Explanation
Op code Operand
Direct addressing. Load the contents of the given address to
LDD <address>
ACC
STO <address> Store the contents of ACC at the given address
INC <register> Add 1 to the contents of the register (ACC or IX)
ADD <address> Add the contents of the given address to the contents of ACC
Bitwise AND operation of the contents of ACC with the
AND <address>
contents of <address>
CMP #n Compare the contents of ACC with the number n
JMP <address> Jump to the given address
Following a compare instruction, jump to <address> if the
JPE <address>
compare was True
Following a compare instruction, jump to <address> if the
JGT <address> content of ACC is greater than the number used in the
compare instruction
END End the program and return to the operating system

© UCLES 2016 9608/33/M/J/16 [Turn over


249
14

(c) Part of the assembly code is:

Op code Operand
SENSORS: B00001010
COUNT: 0
VALUE: 1
LOOP: LDD SENSORS
AND VALUE
CMP #0
JPE ZERO
LDD COUNT
INC ACC
STO COUNT
ZERO: LDD VALUE
CMP #8
JPE EXIT
ADD VALUE
STO VALUE
JMP LOOP
EXIT: LDD COUNT
TEST: CMP …
JGT ALARM

© UCLES 2016 9608/33/M/J/16


250
15

(i) Dry run the assembly language code. Start at LOOP and finish when EXIT is reached.

BITREG COUNT VALUE ACC


B00001010 0 1

[4]

(ii) The operand for the instruction labelled TEST is missing.

State the missing operand.

.......................................................................................................................................[1]

(iii) The intruder detection system is improved and now has eight sensors.

One instruction in the assembly language code will need to be amended.

Identify this instruction .......................................................................................................

Write the amended instruction ......................................................................................[2]

© UCLES 2016 9608/33/M/J/16


251

Cambridge International Examinations


Cambridge International Advanced Level

COMPUTER SCIENCE 9608/33


Paper 3 Written Paper May/June 2016
MARK SCHEME
Maximum Mark: 75

Published

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.

Cambridge will not enter into discussions about these mark schemes.

Cambridge is publishing the mark schemes for the May/June 2016 series for most Cambridge IGCSE®,
Cambridge International A and AS Level components and some Cambridge O Level components.

® IGCSE is the registered trademark of Cambridge International Examinations.

This document consists of 6 printed pages.

© UCLES 2016 [Turn over


252
Page 2 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2016 9608 33

Question Answer Marks

1 (a) Single line joining all four computers and file server 1
One “terminator” at each end 1

(b)
Statement True False
Computer C uses the IP address of  1
Computer A to indicate that the packet is
for Computer A.
Computer B can read the packet sent from  1
Computer C to Computer A.
The File server routes the packet to  1
Computer A.

(c) (i) Collision 1

(ii) Both stop transmitting 1


Each uses a random time 1
Wait for time period 1
Check for bus status 1
Attempt to re-transmit 1
Max 3

(d) Star topology created 1


A switch has a number of ports 1
Each connects to a single device (using a dedicated cable) 1
Switch provides direct transmission/path from device to device 1
Collisions are no longer possible 1
There are dedicated links from Computer A to Computer C AND from 1
the Server to Computer D
Max 4

2 (a) Examples:
Serial number A mark for
Certificate Authority that issued certificate each
CA digital signature correct
Name of company/organisation/individual/subject/owner owning data item –
Certificate
‘Subject’ public key
Period during which Certificate is valid // some relevant date Max 3

(b) (i) Public 1


The individual keeps their private key private // the public key can be
known by others (the public) 1

(ii) Public 1
The individual does not know the private key of the CA // the individual
only knows the public key of the CA // only the CA can decrypt the
packaged information 1

© Cambridge International Examinations 2016


253
Page 3 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2016 9608 33

(iii) Private 1
‘Only’ the CA’s public key will allow decryption of the Certificate //
proving the certificate was issued by the CA 1

(c) (i) Digital signature 1

(ii) Alexa’s digital certificate 1


(Includes) Alexa’s public key 1
Used to hash message received // produce message digest 1
Generated hash compared to digital signature 1
Max 2

(iii) Examples:
Financial transaction 1
Legal document 1
Software distribution 1
Max 2

3 (a) (i) Examples:


Create / delete virtual machine 1
Existing hardware made available to guest OS // hardware emulation 1
Ensures each virtual machine is protected from actions of another virtual 1
machine Max 2

(ii) Guest operating system:


An operating system running in a virtual machine //
Controls virtual hardware //
OS is being emulated 1

Host operating system:


The operating system that is actually controlling the physical hardware //
the operating system for the physical machine// the OS running the VM 1
software

Guest OS is running under the Host OS software 1


Max 2

(b) (i) Examples:


Trial/use alternative replacement operating system(s) … Two marks
Test to identify possible problems for each
Much easier to create VM with a new OS than create new computer use
system
Maximum
Trial/use alternative replacement web server software … two uses
Test to identify possible problems
Easier to try alternative new software and new OS combinations

To provide some additional service(s)


Trial/test its use - description e.g. a print server

General description point – to provide a safe environment during testing Max 4


(which does not disrupt the web server service)

© Cambridge International Examinations 2016


254
Page 4 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2016 9608 33

(ii) Examples:
Using virtual machine means execution of extra code // emulation of 1
some hardware …

Non-VM installation may not perform in the same way 1


Execution speed slower than non-VM system 1
Problems in judging actual response times 1
at time of maximum traffic needs fastest possible speed 1

Particular hardware may be difficult to emulate 1


Max 2

4 (a)
File organisation method File access method
1
serial direct

sequential sequential 2

random 1

(b) (i) Sequential 1


As all customers get statement … // high hit rate 1
Suitable for batch processing of the records // the records will be
processed one after the other 1
File organised using customer’s unique ID (as primary key field) 1
//
Serial 1
As all customers get statement … // high hit rate 1
Suitable for batch processing of the records // the records will be
processed one after the other 1
Order not important 1

Max 3

(ii) Random 1
Real-time transaction processing 1
Requires fastest access to data 1
No need to search through records 1

Max 3

© Cambridge International Examinations 2016


255
Page 5 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2016 9608 33

(iii) Serial 1
Each new record is appended 1
Transactions are recorded in chronological order 1
File re-organisation not required for each new record // no need for the
records to be sorted
Max 3

5 (a)
A B X
0 0 1
0 1 1
1
1 0 1
1 1 0

(b) (i)
S R Q Q
1 0 0 1
1
1 1 0 1 1

0 1 1 0 1
1
1 1 1 0

0 0 1 1

(ii) S=0R=0 1

Produces Q = 1 , Q =1 // Q and Q have same value 1


But Q and Q should be complements of each other 1
Becomes unstable 1

Max 3

(c) (i) Clock (pulse) 1

(ii) All four possibilities are valid 1


The 1-1 combination changes output to logical complement 1
Unstable state avoided 1
Invalid state cannot occur // the flip-flop is stable 1

Max 1

(d) Memory // data storage 1


Stores a single bit 1

6 (a) (i) Monitoring system 1

(ii) This is not a ‘feedback’ system //


There is no ‘control’ taking place/use of actuators //
No output other than from alarm 1

© Cambridge International Examinations 2016


256
Page 6 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2016 9608 33

(b) Examples:
Pressure … 1 – sensor
If intruder steps on sensor 1–
justification
Infra-red …
If beam cut by intruder Maximum
2 sensors
Motion / ultrasonic…
Detects any movement in an area

Contact / magnetic …
If door / window opened Max 4

(c) (i)
BITREG COUNT VALUE ACC Mark as
follows:
B00001010 0 1 B00001010
B00000000 1 mark for:
1
COUNT
2 2 column
B00001010
VALUE
B00000010 column
0
First two
1 1 values in
2 ACC
column
4 4
B00001010 Rest of
ACC
B00000000 column
4
8 8
B00001010
B00001000
1
2 2
8 Max 4

(ii) #1 1

(iii) CMP #8 1

CMP #128 1

© Cambridge International Examinations 2016


257

Cambridge International Examinations


Cambridge International Advanced Level

COMPUTER SCIENCE 9608/42


Paper 4 Further Problem-solving and Programming Skills May/June 2016
PRE-RELEASE MATERIAL
* 9 4 3 6 5 4 8 1 2 6 *

No Additional Materials are required.


This material should be given to the relevant teachers and candidates as soon as it has been received
at the Centre.

READ THESE INSTRUCTIONS FIRST

Candidates should use this material in preparation for the examination. Candidates should attempt the
practical programming tasks using their chosen high-level, procedural programming language.

This document consists of 10 printed pages and 2 blank pages.

DC (NH/SG) 123568
© UCLES 2016 [Turn over
258
2

This material is intended to be read by teachers and candidates prior to the June 2016 examination for
9608 Paper 4.

Candidates will also benefit from using pre-release materials from previous examinations. These are
available on the teacher support site.

Reminders
The syllabus states:
• there will be questions on the examination paper which do not relate to this pre-release material
• you must choose a high-level programming language from this list:
• Visual Basic (console mode)
• Python
• Pascal / Delphi (console mode)

Note: A mark of zero will be awarded if a programming language other than those listed is used.

The practical skills covered in Paper 2 are a precursor to those required in Paper 4. It is therefore
recommended that the high-level programming language chosen for this paper is the same as that for
Paper 2. This allows for sufficient expertise to be acquired with the opportunity for extensive practice.

Questions on the examination paper may ask the candidate to write:


• structured English
• pseudocode
• program code

A program flowchart should be considered as an alternative to pseudocode for the documenting of an


algorithm design.

Candidates should be confident with:


• the presentation of an algorithm using either a program flowchart or pseudocode
• the production of a program flowchart from given pseudocode (or the reverse)

Declaration of variables

The syllabus document shows the syntax expected for a declaration statement in pseudocode.

DECLARE <identifier> : <data type>

It is appreciated that candidates who use Python as their chosen language will not be familiar with the
concept of declaring all variables with their data type before they are used.

However, answers using Python will be required, instead of a declaration statement, to include a
comment statement, documenting the identifier name with its intended data type.

The question will clarify this with a wording and answer layout such as:

(i) Write program code for the new design.

Visual Basic and Pascal: You should include declaration statements for variables.
Python: You should show a comment statement for each variable used with its data type.

Programming language ...................................................................................................

..........................................................................................................................................

..........................................................................................................................................

© UCLES 2016 9608/42/PRE/M/J/16


259
3

Structured English – Variables

An algorithm written in pseudocode requires that all variables have been identified. This may not be
the case if the initial attempt at the algorithm design is in structured English. The candidate will then be
required to identify the variables from the question.

© UCLES 2016 9608/42/PRE/M/J/16 [Turn over


260
4

Jackson Structured Programming (JSP)


Key focus: JSP data
structure diagrams

A JSP data structure diagram is used to represent the data used by a problem.

The tasks that follow introduce you to the symbols used.

Task 1

1.1 This symbol is used in a JSP data structure diagram. What is it used to represent?

• a data item or data component


• a subroutine
• a procedure
• a function

1.2 Which one statement correctly describes this diagram?

A B C

• It shows a sequence of data items which can be presented in any order.


• It shows alternative data items.
• It shows a sequence of data items structured in the order A, then B, then C.

1.3 Which are the three true statements for the JSP data structure diagram shown below?

A B C

1 Data structure X is made up of items A, then B, then C.


2 Data structure X is made up of a combination of items A, B and C.
3 The JSP data structure diagram illustrates sequence.
4 The JSP data structure diagram shows stepwise refinement.

1.4 A customer transaction, CustomerTransaction, consists of:


• a customer number, CustomerNumber
• a product code, ProductCode
• the quantity, Quantity

in this given order.


Key focus:
Using ‘sequence’ …
Draw the JSP data structure diagram.

© UCLES 2016 9608/42/PRE/M/J/16


261
5

1.5 This symbol is used in a JSP data structure diagram. What is it used to represent?

• sequence
• selection
• a procedure
• iteration

Task 2

A train, Train, consists of an engine, Engine, followed by a carriage, Carriage. Sometimes there is
a second Engine at the rear of the train.

Draw the JSP data structure diagram.

Task 3 Key focus:


Using ‘sequence’ …
An employee record Record consists of:

• the employee name EmployeeName


• the address EmployeeAddress
• a pay code EmployeePayCode, which is either Full, Part Casual

in this given order.

Draw the JSP data structure diagram.

Task 4

4.1 This symbol is used in a JSP data structure diagram. What is it used to represent?

• a process, action or operation on a data item


*
• iteration of data item
• selection of a data item
• a procedure

4.2 A Train consists of an Engine followed by one or more Carriages. Sometimes there is a
second Engine at the rear of the train.
Key focus:
Draw the JSP data structure diagram. Using ‘iteration’ …

4.3 An examination paper, ExamPaper, consists of a front page, Front, followed by at least one
question, Question.

Draw the JSP data structure diagram.

© UCLES 2016 9608/42/PRE/M/J/16 [Turn over


262
6

Task 5

A shipping company has a number of merchant ships. Data are recorded for all the voyages made by
each ship.

The data are stored in a file ShipFile. The file has:

• a file header, FileHeader, which shows the date the file was last updated
• a file body, FileBody, which contains data for all the ships
• a file trailer, FileTrailer, which marks the end of the file

The data for each ship are made up of the name of the ship followed by the data records for each
voyage made. There may be a ship record for a ship which has not made any voyages so far.

ShipFile 1

FileHeader FileBody FileTrailer 2

*
Ship 3

*
ShipName ShipVoyage 4

To build up the JSP data structure diagram:

1 the file has the name ShipFile.

2 the file is made up of the sequence of data components stated in the bulleted list above the
diagram.

Note:

• A component which has no derived lower level component(s) is called an elementary component.
FileHeader and FileTrailer are both elementary components.

• It may have been tempting to have the iterated data item Ship one line above (which would seem
to avoid the use of the FileBody item. However, this would have resulted in a sequence of ‘mixed-
type components’ at the same level. This must always be avoided.

© UCLES 2016 9608/42/PRE/M/J/16


263
7

3 The component Ship is an iteration, as it consists of the data for several ships.

4 We have ‘mixed-type components’ at the same level. That is ShipName (elementary) and
ShipVoyage (iterated). The solution therefore is the same as earlier. This gives the final diagram
below:

ShipFile

FileHeader FileBody FileTrailer

*
Ship

ShipName ShipBody

*
ShipVoyage

Key focus:
A data structure
Task 6 diagram for output

A JSP data structure diagram can also be used to describe the data requirements for a printed report.

This was hinted at in Task 4.3.

A report, Report, is made up of a number of pages, Page. Each page consists of a possible heading,
Heading, followed by a number of lines, Line.

Draw the JSP data structure diagram.

© UCLES 2016 9608/42/PRE/M/J/16 [Turn over


264
8

Logic Programming
Key focus:
Task 7 Lists

Logic programming can use a data structure called a list. The list items are enclosed inside square
brackets. Each item is separated by a comma. The list can be given an identifier name.

The following is a list with a sequence of elements.

[budapest,paris,london,singapore,dhaka,oslo,brussels,amsterdam,cairo]

[] denotes an empty list.

A variable can be used to represent a list.

Cities represents [budapest,paris,london,singapore,dhaka,oslo,


brussels,amsterdam,cairo]

The operator | is used with a list.


Key focus:
For example, [X|Y] denotes a list with: The ‘⎜’ list operator

X a variable representing the first list element, the head


Y a variable consisting of the remaining list elements, the tail

Example:

If Cities represents [X|Y]

• X = budapest
• Y = [paris,london,singapore,dhaka,oslo,brussels,amsterdam,cairo]

Note:
The head is always a list item
The tail is always a list
Predicates can be defined and used to manipulate and interrogate a list.

Assume the predicate isEmpty is defined in the knowledge base to return TRUE or FALSE.

isEmpty(X) returns: Key focus:


Predicates with lists
TRUE when X = []
FALSE when X has one or more elements

Example:

isEmpty(Cities) would return FALSE.

© UCLES 2016 9608/42/PRE/M/J/16


265
9

7.1

The list [gibraltar,hanoi] is denoted as [A|B]

State the values of A and B.

A = ......................................................................................

B = ......................................................................................

7.2

The following two lists are identical:

[kingston,rome,riga|C] = [kingston,rome,riga,bangkok,minsk]

State the value of C.

C = ......................................................................................

7.3

The following two lists are identical:

[suva,stanley] = [D,E|F]

State the value of F.

F = ......................................................................................

Consider this second predicate:

removeAndCompare(A,B,C)

Remove any elements from list A which are also present in list B.
Compare the amended list A with list C.

If the lists are identical, the predicate returns TRUE, otherwise returns FALSE.

7.4.1

removeAndCompare([moscow,ottowa,monaco],
[monaco,london],
[moscow,ottowa,monaco])
What is returned by this predicate?

......................................................................................

© UCLES 2016 9608/42/PRE/M/J/16 [Turn over


266
10

7.4.2

removeAndCompare([orange,banana],[ ],[orange,banana])

What is returned by this predicate?

......................................................................................

© UCLES 2016 9608/42/PRE/M/J/16


267

Cambridge International Examinations


Cambridge International Advanced Level
* 6 2 5 0 5 5 1 9 0 4 *

COMPUTER SCIENCE 9608/42


Paper 4 Further Problem-solving and Programming Skills May/June 2016
2 hours
Candidates answer on the Question Paper.
No Additional Materials are required.
No calculators allowed.

READ THESE INSTRUCTIONS FIRST

Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.

Answer all questions.

No marks will be awarded for using brand names of software packages or hardware.

At the end of the examination, fasten all your work securely together.

The number of marks is given in brackets [ ] at the end of each question or part question.

The maximum number of marks is 75.

This document consists of 19 printed pages and 1 blank page.

DC (LM/SG) 124303
© UCLES 2016 [Turn over
268
2

1 A linked list abstract data type (ADT) is to be used to store and organise surnames.

This will be implemented with a 1D array and a start pointer. Elements of the array consist of a
user-defined type. The user-defined type consists of a data value and a link pointer.

Identifier Data type Description


LinkedList RECORD User-defined type
Surname STRING Surname string
Ptr INTEGER Link pointers for the linked list

(a) (i) Write pseudocode to declare the type LinkedList.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

(ii) The 1D array is implemented with an array SurnameList of type LinkedList.

Write the pseudocode declaration statement for SurnameList. The lower and upper
bounds of the array are 1 and 5000 respectively.

.......................................................................................................................................[2]

(b) The following surnames are organised as a linked list with a start pointer StartPtr.

StartPtr: 3
1 2 3 4 5 6 5000
Surname Liu Yang Chan Wu Zhao Huang …
Ptr 4 5 6 2 0 1 …

State the value of the following:

(i) SurnameList[4].Surname .......................................................................................[1]

(ii) SurnameList[StartPtr].Ptr ................................................................................[1]

© UCLES 2016 9608/42/M/J/16


269
3

(c) Pseudocode is to be written to search the linked list for a surname input by the user.

Identifier Data type Description


ThisSurname STRING The surname to search for
Current INTEGER Index to array SurnameList
Index to array SurnameList. Points to the
StartPtr INTEGER
element at the start of the linked list

(i) Study the pseudocode in part (c)(ii).

Complete the table above by adding the missing identifier details. [2]

(ii) Complete the pseudocode.

01 Current ← ..............................................................................................................
02 IF Current = 0
03 THEN
04 OUTPUT .........................................................................................................
05 ELSE
06 IsFound ← .................................................................................................
07 INPUT ThisSurname
08 REPEAT
09 IF ............................................................................. = ThisSurname
10 THEN
11 IsFound ← TRUE
12 OUTPUT "Surname found at position ", Current
13 ELSE
14 // move to the next list item
15 .....................................................................................................
16 ENDIF
17 UNTIL IsFound = TRUE OR .....................................................................
18 IF IsFound = FALSE
19 THEN
20 OUTPUT "Not Found"
21 ENDIF
22 ENDIF
[6]

© UCLES 2016 9608/42/M/J/16 [Turn over


270
4

2 (a) (i) State what is meant by a recursively defined procedure.

...........................................................................................................................................

.......................................................................................................................................[1]

(ii) Write the line number from the pseudocode shown in part (b) that shows the

procedure X is recursive. .............................. [1]

(b) The recursive procedure X is defined as follows:

01 PROCEDURE X(Index, Item)


02 IF MyList[Index] > 0
03 THEN
04 IF MyList(Index) >= Item
05 THEN
06 MyList[Index] ← MyList[Index + 1]
07 ENDIF
08 CALL X(Index + 1, Item)
09 ENDIF
10 ENDPROCEDURE

An array MyList is used to store a sorted data set of non-zero integers. Unused cells contain
zero.

1 2 3 4 5 6 7 8 9 10

MyList 3 5 8 9 13 16 27 0 0 0

© UCLES 2016 9608/42/M/J/16


271
5

(i) Complete the trace table for the dry-run of the pseudocode for the procedure
CALL X(1, 9).

MyList
Index Item 1 2 3 4 5 6 7 8 9 10
1 9 3 5 8 9 13 16 27 0 0 0

[4]

(ii) State the purpose of procedure X when used with the array MyList.

...........................................................................................................................................

.......................................................................................................................................[1]

© UCLES 2016 9608/42/M/J/16 [Turn over


272
6

3 A car hire company hires cars to customers. Each time a car is hired, this is treated as a transaction.

For each transaction, the following data are stored.

For the customer:

• customer name
• ID number

For the hire:

• car registration
• hire start date
• number of days hired

The transaction data are stored in a text file HIRE-TRANS. The file is made up of a file body,
F_BODY, and a file trailer, F_TRAILER.

F_BODY has one transaction, TRANS, on each line.

(a) The first step in Jackson Structured Programming (JSP) design is to produce a JSP data
structure diagram.

Complete the following JSP data structure diagram.

HIRE-TRANS

F_BODY

[7]
© UCLES 2016 9608/42/M/J/16
273
7

(b) The computer system will produce many printed reports.

One report is CAR_REPORT. This displays all hire data for all cars.

For each car, the following data are displayed:

• the car data


• a list of all the hires
• the total number of hires

A car with zero hires is not included on the report.

Complete the following CAR_REPORT JSP data structure diagram.

CAR_REPORT

*
CAR

No hires One or more hires

HIRE_LIST

HIRE

[5]

© UCLES 2016 9608/42/M/J/16 [Turn over


274
8

4 When a car reaches a certain age, a safety assessment has to be carried out. A car’s brakes and
tyres must be tested. The tyre test result and the brakes test result for each car are recorded. If the
car passes the assessment, a safety certificate is issued.

Cars have a unique three-character registration.

The following knowledge base is used:

01 car(a05).
02 car(h04).
03 car(a03).
04 car(h07).
05 car(a23).
06 car(p05).
07 car(b04).
08 carRegYear(a05, 2015).
09 carRegYear(h04, 2013).
10 carRegYear(a03, 2008).
11 carRegYear(h07, 2011).
12 carRegYear(a23, 2008).
13 carRegYear(p05, 2014).
14 carRegYear(b04, 2014).
15 testBrakes(h07, pass).
16 testTyres(h07, fail).
17 testBrakes(a03, fail).
18 testTyres(a03, fail).
19 testBrakes(a23, pass).
20 testTyres(a23, pass).
21 carAssessmentDue if carRegYear(Car, RegYear)
and RegYear <= DeadlineYear.
22 issueCertificate(Car) if testTyres(Car, Result) and
testBrakes(Car, Result) and Result = pass.

(a) (i) DeadlineYear is assigned value 2011.

Identify the car registrations for cars which are due to be tested.

.......................................................................................................................................[1]

(ii) State how clause 22 determines whether or not a safety certificate will be issued.

...........................................................................................................................................

.......................................................................................................................................[1]

© UCLES 2016 9608/42/M/J/16


275
9

(b) If a car fails one of the two tests, a retest is allowed.

Write a new rule for this.

retestAllowed(..............................) if ............................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

(c) Logic programming uses a data structure called a list.

A new fact is added to the knowledge base.

23 carList = [a03,p05,b04,h04,h07,a23].

The following notation and operators are to be used with a list:

[X|Y] denotes a list with:

• X the first list element


• Y the list consisting of the remaining list elements

[] denotes an empty list

(i) The list [a07,p03] is denoted by [A|B]

State the value of A and B.

A = ......................................................................................

B = ...................................................................................... [2]

(ii) The lists [c03,d02,n05|C] and [c03,d02,n05,p05,m04] are identical.

State the value of C.

C = ..................................................................................... [1]

(iii) The list [a06,a02] is denoted by [D,E|F]

State the value of F.

F = ..................................................................................... [1]

© UCLES 2016 9608/42/M/J/16 [Turn over


276
10

(d) The predicate conCatCompare is defined as a rule and returns TRUE or FALSE as follows:

conCatCompare(X, Y, Z)

Concatenates the lists X and Y and compares the new list with
list Z.

If equal, the clause evaluates to TRUE, otherwise FALSE.

Consider the clause:

conCatCompare(X, Y, [a7,b6,c4])

If:

• the clause evaluates to TRUE


• and Y represents the list [a7, b6, c4]

State the value of X.

X = .................................................................................................................................[1]

© UCLES 2016 9608/42/M/J/16


277
11

5 (a) A program calculates the exam grade awarded from a mark input by the user. The code is
written as a function CalculateGrade.

The function:

• has a single parameter Mark of INTEGER data type


• returns the grade awarded Grade of STRING data type

The logic for calculating the grade is as follows:

Mark Grade
Under 40 FAIL
40 and over and under 55 PASS
55 and over and under 70 MERIT
70 and over DISTINCTION

The programmer designs the following table for test data:

Mark Description Expected result (Grade)


Normal
Abnormal
Extreme/Boundary

(i) Complete the table above. [3]

(ii) State why this table design is suitable for black box testing.

...........................................................................................................................................

.......................................................................................................................................[1]

© UCLES 2016 9608/42/M/J/16 [Turn over


278
12

(b) When designing and writing program code, explain what is meant by:

• an exception
• exception handling

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

(c) A program is to be written to read a list of exam marks from an existing text file into a 1D array.

Each line of the file stores the mark for one student.

State three exceptions that a programmer should anticipate for this program.

1 ................................................................................................................................................

...................................................................................................................................................

2 ................................................................................................................................................

...................................................................................................................................................

3 ................................................................................................................................................

...............................................................................................................................................[3]

© UCLES 2016 9608/42/M/J/16


279
13

(d) The following pseudocode is to read two numbers:

01 DECLARE Num1 : INTEGER


02 DECLARE Num2 : INTEGER
03 DECLARE Answer : INTEGER
04 TRY
05 OUTPUT "First number..."
06 INPUT Num1
07 OUTPUT "Second number..."
08 INPUT Num2
09 Answer ← Num1 / (Num2 – 6)
10 OUTPUT Answer
11 EXCEPT ThisException : EXCEPTION
12 OUTPUT ThisException.Message
13 FINALLY
14 // remainder of the program follows

29
30 ENDTRY

The programmer writes the corresponding program code.

A user inputs the number 53 followed by 6. The following output is produced:

First number...53
Second number...6
Arithmetic operation resulted in an overflow

(i) State the pseudocode line number which causes the exception to be raised.

................................................... [1]

(ii) Explain the purpose of the pseudocode on lines 11 and 12.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]
© UCLES 2016 9608/42/M/J/16 [Turn over
280
14

6 In a board game, one player has white pieces and the other player has black pieces. Players take
alternate turns to move one of their pieces. White always makes the first move.

The game ends if:

• a player is unable to make a move when it is their turn. In this case, there is no winner. This is
called ‘stalemate’.
• a player wins the game as a result of their last move and is called a ‘winner’.

(a) A state-transition diagram is drawn to clarify how the game is played.

Complete the following state-transition diagram.

WHITE
WINS
No move
:+,7(·6 possible
TURN

Stalemate
BLACK moves

%/$&.·6 BLACK
TURN WINS

Winning
move
[4]
(b) The layout of the board at the start of the game is shown below:

x
y 1 2 3 4 5 6 7 8
1

8
© UCLES 2016 9608/42/M/J/16
281
15

The programmer decides to use a 2D array to represent the board. The index numbering to
be used is as shown.

Each square on the board is either occupied by one piece only, or is empty.

The data stored in the array indicate whether or not that square is occupied, and if so, with a
black piece or a white piece.

(i) Write program code to initialise the contents of the array to represent the board at the
start of the game. Use characters as follows for each square:

'B' represents a black piece


'W' represents a white piece
'E' represents an empty square

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 .....................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[4]
© UCLES 2016 9608/42/M/J/16 [Turn over
282
16

(ii) When a piece is to be moved, a procedure will calculate and output the possible
destination squares for the moving piece.

A piece can move one or more squares, in the x or y direction, from its current position.

This will be a move:

• either to an empty square, with no occupied squares on the way

• or to a square containing a piece belonging to another player, with no occupied


squares on the way. The other player’s piece is then removed.

For example, for the circled black piece there are nine possible destination squares. Each
of the two destination squares contains a white piece which would be removed.

x
y 1 2 3 4 5 6 7 8
The program requires a procedure ValidMoves.
1

2 It needs three parameters:

3 • PieceColour – colour of the moving piece


• xCurrent – current x position
4 • yCurrent – current y position
5 The procedure will calculate all possible destination
squares in the x direction only.
6

Example output for the circled black piece is:

Possible moves are:


Moving LEFT
3 4
2 4 REMOVE piece
Moving RIGHT
5 4
6 4
7 4

Write program code for procedure ValidMoves with the following procedure header:

PROCEDURE ValidMoves(PieceColour : CHAR, xCurrent : INTEGER,


yCurrent : INTEGER).

© UCLES 2016 9608/42/M/J/16


283
17

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 .....................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
© UCLES 2016 9608/42/M/J/16 [Turn over
284
18

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[5]

© UCLES 2016 9608/42/M/J/16


285
19

(c) The problem is well suited to an object-oriented design followed by object-oriented


programming.

(i) Describe how classes and objects could be used in this problem.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(ii) For a class you identified in part(c)(i), state two properties and two methods.

Class ..............................................

Properties

1 ........................................................................................................................................

2 ........................................................................................................................................

Methods

1 ........................................................................................................................................

2 ........................................................................................................................................
[2]

© UCLES 2016 9608/42/M/J/16


286

Cambridge International Examinations


Cambridge International Advanced Level

COMPUTER SCIENCE 9608/42


Paper 4 Written Paper May/June 2016
MARK SCHEME
Maximum Mark: 75

Published

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.

Cambridge will not enter into discussions about these mark schemes.

Cambridge is publishing the mark schemes for the May/June 2016 series for most Cambridge IGCSE®,
Cambridge International A and AS Level components and some Cambridge O Level components.

® IGCSE is the registered trademark of Cambridge International Examinations.

This document consists of 15 printed pages.

© UCLES 2016 [Turn over


287
Pag
P ge 2 Mar
M k Sch
S hemmee Sylllab
bus Pape
P er
C mb
Cam brid
dge
e In
nte
ern
natiion
nal A Le
eve
el – May
M y/J
Jun
ne 2016
6 9 08
960 4
42

Q estio
Qu on A
An
nsw
werr Mark
ks

1 (a)) (i)
( TY
YPE
E Lin
L nk
ked
dLi
ist
t 1 3

(D
DEC
CLA
ARE
E) S
Sur
rna
ame
e : ST
TRIING
G 1
(D
DEC
CLA
ARE
E) P
Ptr I TE
r : IN EGE
ER

EN
NDT
TYP
PE 1

Ac
cce
eptt:
Li
ink dList : RE
ked ECO
ORD 1

Su
urn me : S
nam STR
RIN
NG 1
tr : IN
Pt NTEG
GER
R

EN
NDR
REC
COR
RD
D 1

Ac
cce
eptt:
TY
YPE
E Lin
L nkked
dLi
ist
t = RE
ECO
ORD
D 1

Su
urn
nam
me : S
STR
RIN
NG 1
tr : IN
Pt NTEG
GER
R

EN
NDT
TYP
PE / E
END
DRE
ECO
ORD 1

Ac
cce
eptt:
ST
TRU
UCT
TUR RE L
Lin
nke
edL
List
t 1

(D
DEC
CLA
ARE
E) S
Sur
rna
ame
e : ST
TRIING
G 1
(D
DEC
CLA
ARE
E) P
Ptr I TE
r : IN EGE
ER

EN
NDS RUCTUR
STR RE 1

Accce
ept AS OF in
S / O nste
ead o
of :

(iii) (D
DEC
CLA E) S
ARE Sur
rna
ame
eLis
st[
[1:
:50
000
0] : Lin
L nke
edL
List
t 2

Accce
ept AS
S / O OF innsteead o
of :
Accce
ept () instteaad of []
ept witho
Accce outt lowe
er bou
b undd
Ind
dexx sep
s para
ato
or can
c n bee , : ...

(b)) (i)
( Wu
u 1
Accce
ept with quote
es

(iii) 6 1

(c)) (i)
( Is
sFo nd + relevantt descrip
oun ptio
on 1 2
BO
OOL
LEA
AN 1

© Ca
amb
brid
dge
e In
nterrnattion
nal Ex
xam
mina
atio
ons
s 20
016
6
288
Page 3 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2016 9608 42

Question Answer Marks

(ii) Accept () instead of [] 6


01 Current ← StartPtr
02 IF Current = 0
03 THEN
OUTPUT "Empty List" (or similar message)
04
(accept without quotes) Reject “Error”
05 ELSE
06 IsFound ← FALSE
07 INPUT ThisSurname
08 REPEAT
09 IF SurnameList[Current].Surname = ThisSurname
10 THEN
11 IsFound ← TRUE
12 OUTPUT "Surname found at position ", Current
13 ELSE
14 // move to the next list item
15 Current ← SurnameList[Current].Ptr
16 ENDIF
17 UNTIL IsFound = TRUE OR Current = 0
18 IF IsFound = FALSE
19 THEN
20 OUTPUT "Not Found"
21 ENDIF
22 ENDIF

Accept = for assignment

2 (a) (i) A procedure which is defined in terms of itself // A procedure which makes a call to 1
itself // A procedure that calls itself

(ii) 08 // 8 1

© Cambridge International Examinations 2016


289
Page 4 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2016 9608 42

Question Answer Marks

(b) (i) MyList 4


Index Item 1 2 3 4 5 6 7 8 9 10

1 9 3 5 8 9 13 16 27 0 0 0

13
4

5 16

6 27

7 0

Note: Final mark only if no additional entries in table


Accept last row to show all final values

(ii) Any one from: 1


Deletes/removes parameter value/ Item (from the array MyList)
// Deletes the first entry (in MyList) that equals or is bigger than Item

Overwrites Item by moving subsequent items up/down/across/left R right

© Cambridge International Examinations 2016


290
Page 5 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2016 9608 42

Question Answer Marks

3 (a) 7
HIRE-TRANS

F_BODY F_TRAILER

TRANS

Customer
data Hire data

Customer Hire start Number of


CustomerID Car Reg
Name date days hired

Mark as follows:
Label F_TRAILER 1
Label TRANS 1

Customer box (Accept label Customer) 1


Hire box (Accept label Hire) 1

Customer fields : Customer Name, CustomerID/IDnumber 1


Hire fields: Car Reg 1
Hire fields: Hire start date, Number of days hired 1

accept level 5 fields in any order


Ignore parent

© Cambridge International Examinations 2016


291
Page 6 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2016 9608 42

Question Answer Marks

(b) 5

Mark as follows:
Selection symbol x 2 (Car-hire / No car-hire) 1
Labelling for CAR_HIRE / NO_HIRE (accept similar labels*) 1
Labelling for Car registration and Car total / Total hires 1
Iteration symbol for HIRE (accept in HIRE_LIST as a BOD) 1
Labelling for start date and number of days (as per diagram) 1

* For CAR_HIRE label:


Accept: Hires / hired / Car data / hire data / hire record / one or more hires

© Cambridge International Examinations 2016


292
Page 7 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2016 9608 42

Question Answer Marks

4 (a) (i) a03, h07, a23 1


accept in any order, must be lower case

(ii) The car must pass (both) brake test and tyres test 1

(b) retestAllowed(ThisCar) 3
1
If (testBrakes(ThisCar, pass) and testTyres(ThisCar, fail))
1
or (testBrakes(ThisCar, fail) and testTyres(ThisCar, pass))
1
(one mark per bold underlined all correct)
accept another variable instead of ThisCar, but must be same throughout.

(c) (i) a07 2


[p03]

must be []
must be lower case, but don’t penalise twice, so follow through from part(b)

(ii) [p05,m04] 1

(iii) [ ] 1

(d) [ ] 1

5 (a) (i) Mark Description Expected result (Grade) 3

Normal FAIL/PASS/MERIT/DISTINCTION
Abnormal Error
Extreme/Boundary FAIL/PASS/MERIT/DISTINCTION

3 × (mark + matching grade)


for abnormal data accept negative values, non-integer values, Expected Result: Error
0 and marks above 100 are still acceptable values
Do not accept FAIL in expected result column for Abnormal data

(ii) (The programmer is) concerned only with the input (i.e. the mark) to the function and 1
monitoring the expected output (i.e. the grade)
// can compare expected result and actual result

(b) Exception: 3
1. situation causing a crash / run-time error / fatal error 1

Exception handling:
2. code which is called when a run-time error occurs 1
3. … to avoid the program terminating/crashing 1

© Cambridge International Examinations 2016


293
Page 8 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2016 9608 42

Question Answer Marks

(c) 1 Open a non-existent file Max 3


2 Directory path does not exist
3 Attempt to read past the end of the file // attempt to read an empty file
4 Array subscript is out of range
5 Non-integer value / corrupt data read
6 File already open in a different mode // wrong file permissions

(d) (i) 09 // 9 1

(ii) 1 Line 11 catches exceptions (only) between lines 05 and 10 1 Max 3


2 Line 11 stops the program from crashing 1
3 Different exception types recognised 1
4 Each exception type has an appropriate message output 1
5 The program language has an (object) type EXCEPTION 1
6 ThisException is the instance of EXCEPTION which has been raised 1
7 EXCEPTION objects have a ‘Message’ property
// the message property for ThisException is
“Arithmetic operation resulted in an overflow” 1

6 (a) 4

Max 3 marks if extra states/transitions added.

© Cambridge International Examinations 2016


294
Page 9 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2016 9608 42

Question Answer Marks

(b) (i) Mark as follows: 4


1 Declaration for array (character or string data type)
2 FOR loop for x going from 1 to 8, generating column index used in array
3 FOR loop for y going from 1–2, 3–6, 7–8
(Accept all squares being set to 'E' and then overwritten with 'B', 'W'
respectively)
4 Setting squares to 'B', 'E', 'W' (must be in quotes, accept single or double)

(ii) Mark as follows: Max 5


1 Procedure heading and declaration of 2 local variables 1
2 Establishing the stopper colour – opposite to the mover 1
3 Test for piece in column 1 (x>1) // column 8 (x<8) 1
4 Test for ‘E’ 1
5 Correct method for moving left // for moving right 1
6 until edge of board reached 1
7 until other colour (stopper colour) encountered 1
8 until own colour encountered (PieceColour) 1
9 Correct output for cell indexes 1
(accept for moving in 1 direction only)
10 including the ‘REMOVE’ message 1

Note: must use given parameter identifiers: PieceColour, xCurrent, yCurrent

(c) (i) Classes could be designed for : Max 2


• the board
• a piece
Containment (Board contains Pieces)
The pieces are instances/objects (of the Piece class)

© Cambridge International Examinations 2016


295
Page 10 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2016 9608 42

Question Answer Marks

(ii) Accept any reasonable answer, for example: Max 2

BOARD class:

Properties:
• Number of squares / size / dimensions
• Current state of all squares

Methods: –
• Set the starting board
• Capture the finishing state of the board
• Display the state of the board after each move

PIECE class:
Properties:
• Starting x position
• Starting y position
• Current x position
• current y position
• Colour
• State / Removed / Active

Methods:
• Move piece
• Remove piece

Mark as follows:
two correct responses are worth 1 mark

Accept other classes: Game, Player

© Cambridge International Examinations 2016


296
Page 11 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2016 9608 42

Programming code

6 (b) (i)

VB.NET
Dim Board(8, 8) As Char
Dim Row, Column As Integer
For Row = 1 To 2
For Column = 1 To 8
Board(Row, Column) = "B"
Next
Next
For Row = 3 To 6
For Column = 1 To 8
Board(Row, Column) = "E"
Next
Next
For Row = 7 To 8
For Column = 1 To 8
Board(Row, Column) = "W"
Next
Next

PASCAL
var Row, Column : integer;
Board : array[1..8, 1..8] of char;
begin
for Row := 1 to 2 do
for Column := 1 to 8 do
Board[Row, Column] := 'B';
for Row := 3 to 6 do
for Column := 1 to 8 do
Board[Row, Column] := 'E';
for Row := 7 to 8 do
for Column := 1 to 8 do
Board[Row, Column] := 'W';
end.

© Cambridge International Examinations 2016


297
Page 12 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2016 9608 42

PYTHON
Board = [["" for j in range(9)] for i in range(9)]
for Row in range(1, 3) :
for Column in range(1, 9) :
Board[Row][Column] = "B"
for Row in range(3, 7) :
for Column in range(1, 9) :
Board[Row][Column] = "E"
for Row in range(7, 9) :
for Column in range(1, 9) :
Board[Row][Column] = "W"

Alternative declarations of Board array :

Board = [[""] * 9 for i in range(9)]

Board = [[]]
for i in range(9) :
for j in range(9) :
Board.append("")

Instead of initialising with empty string, could initialise with ‘E’. this would then only require ‘B’ and ‘W’
loops later.

For example:

Board = [["E"] * 9 for i in range(9)] // Board =[["E"]*9]*9


for Row in range(1, 3) :
for Column in range(1, 9) :
Board[Row][Column] = "B"
for Row in range(7, 9) :
for Column in range(1, 9) :
Board[Row][Column] = "W"

Board =[]
for i in range(9):
Board.append(["E"]*9)

© Cambridge International Examinations 2016


298
Page 13 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2016 9608 42

6 (b) (ii)

VB.NET
Sub ValidMoves(ByVal PieceColour As Char, ByVal xCurrent As Integer,
ByVal yCurrent As Integer)
Dim i As Integer
Dim StopperColour As Char
Dim NoFurther As Boolean
If PieceColour = "B" Then
StopperColour = "W"
Else
StopperColour = "B"
End If
Console.WriteLine("Possible moves are : ")
If xCurrent <> 1 Then
Console.WriteLine("Moving LEFT . . .")
i = xCurrent – 1
NoFurther = False
do
if Board(i, yCurrent) = "E" Then
Console.WriteLine(i & " " & yCurrent)
End If
if Board(i, yCurrent) = StopperColour Then
Console.WriteLine(i & " " & yCurrent & " REMOVE PIECE")
NoFurther = True
End If
i = i – 1
Loop Until i = 0 Or NoFurther = True
End If
if xCurrent <> 8 Then
Console.WriteLine("Moving RIGHT . . .")
i = xCurrent + 1
NoFurther = False
do
if Board(i, yCurrent) = "E" :
Console.WriteLine(i & " " & yCurrent)
End If
if Board(i, yCurrent) = StopperColour Then
Console.WriteLine(i & " " & yCurrent & " REMOVE PIECE")
NoFurther = True
End If
i = i + 1
Loop Until i = 9 Or NoFurther = True
End If
End Sub

© Cambridge International Examinations 2016


299
Page 14 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2016 9608 42

PASCAL
procedure ValidMoves(PieceColour : char; xCurrent, yCurrent : integer);
var StopperColour : char;
i : integer;
NoFurther : boolean;
begin
if (PieceColour = 'B') then
StopperColour := 'W'
else
StopperColour := 'B';
writeln('Possible moves are : ');
if (xCurrent <> 1) then
begin
writeln('Moving LEFT . . . ');
i := xCurrent – 1;
NoFurther := false;
repeat
if (Board[i, yCurrent] = 'E') then
writeln(intToStr(i) + ' ' + intToStr(yCurrent));
if (Board[i, yCurrent] = StopperColour) then
begin
writeln(intToStr(i) + ' ' + intToStr(yCurrent) + ' REMOVE
PIECE');
NoFurther := true;
end;
i := i – 1;
until ((i = 0) or (NoFurther = true));
end;
if (xCurrent <> 8) then
begin
writeln('Moving RIGHT . . . ');
i := xCurrent + 1;
NoFurther := false;
repeat
if (Board[i, yCurrent] = 'E') then
writeln(intToStr(i) + ' ' + intToStr(yCurrent));
if (Board[i, yCurrent] = StopperColour) then
begin
writeln(intToStr(i) + ' ' + intToStr(yCurrent) + ' REMOVE
PIECE');
NoFurther := true;
end;
i := i + 1;
until ((i = 9) or (NoFurther = true));
end;
end;

© Cambridge International Examinations 2016


300
Page 15 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2016 9608 42

PYTHON

def ValidMoves(PieceColour, xCurrent, yCurrent) :


if PieceColour == "B" :
StopperColour = "W"
else :
StopperColour = "B"
print("Possible moves are : ")
if xCurrent != 1 :
print("Moving LEFT . . .")
i = xCurrent – 1
NoFurther = False
while i > 0 and NoFurther == False :
if Board[i][yCurrent] == "E" :
print(str(i) + " " + str(yCurrent))
if Board[i][yCurrent] == StopperColour :
print(str(i) + " " + str(yCurrent) + " REMOVE PIECE")
NoFurther = True
i = i – 1
if xCurrent != 8 :
print("Moving RIGHT . . .")
i = xCurrent + 1
NoFurther = False
while i < 9 and NoFurther == False :
if Board[i][yCurrent] == "E" :
print(str(i) + " " + str(yCurrent))
if Board[i][yCurrent] == StopperColour :
print(str(i) + " " + str(yCurrent) + " REMOVE PIECE")
NoFurther = True
i = i + 1

© Cambridge International Examinations 2016


301

Cambridge International Examinations


Cambridge International Advanced Level
* 2 1 5 5 3 9 6 6 5 3 *

COMPUTER SCIENCE 9608/31


Paper 3 Advanced Theory October/November 2016
1 hour 30 minutes
Candidates answer on the Question Paper.
No Additional Materials are required.
No calculators allowed.

READ THESE INSTRUCTIONS FIRST

Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.

Answer all questions.


No marks will be awarded for using brand names of software packages or hardware.

At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.

The maximum number of marks is 75.

This document consists of 11 printed pages and 1 blank page.

DC (NF/AR) 116626/4
© UCLES 2016 [Turn over
302
2

1 In a particular computer system, real numbers are stored using floating-point representation with:

• 12 bits for the mantissa


• 4 bits for the exponent
• two’s complement form for both mantissa and exponent

(a) Calculate the floating-point representation of + 2.5 in this system. Show your working.

Mantissa Exponent


...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [3]

(b) Calculate the floating-point representation of − 2.5 in this system. Show your working.

Mantissa Exponent


...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [3]

© UCLES 2016 9608/31/O/N/16


303
3

(c) Find the denary value for the following binary floating-point number. Show your working.

Mantissa Exponent

0
•0 1 1 0 0 0 0 0 0 0 0 0 0 1 1

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [3]

(d) (i) State whether the floating-point number given in part (c) is normalised or not normalised.

...................................................................................................................................... [1]

(ii) Justify your answer given in part (d)(i).

...........................................................................................................................................

...................................................................................................................................... [1]

(e) The system changes so that it now allocates 8 bits to both the mantissa and the exponent.

State two effects this has on the numbers that can be represented.

1 ...............................................................................................................................................

...................................................................................................................................................

2 ...............................................................................................................................................

.............................................................................................................................................. [2]

© UCLES 2016 9608/31/O/N/16 [Turn over


304
4

2 There are four stages in the compilation of a program written in a high-level language.

(a) Four statements and four compilation stages are shown below.

Draw a line to link each statement to the correct compilation stage.

Statement Compilation stage

This stage removes any


comments in the program Lexical analysis
source code.

This stage could be


Syntax analysis
ignored.

This stage checks the


grammar of the program Code generation
source code.

This stage produces a


tokenised version of the Optimisation
program source code.

[4]

(b) Write the Reverse Polish Notation (RPN) for the following expressions.

(i) (A + B) * (C − D)

...................................................................................................................................... [2]

(ii) − A / B * 4 / (C − D)

...................................................................................................................................... [3]

© UCLES 2016 9608/31/O/N/16


305
5

(c) An interpreter is executing a program. The program uses the variables w, x, y and z.

The program contains an expression written in infix form. The interpreter converts the infix
expression to RPN. The RPN expression is:

x w z + y − *

The interpreter evaluates this RPN expression using a stack.

The current values of the variables are:

w = 1 x = 2 y = 3 z = 4

(i) Show the changing contents of the stack as the interpreter evaluates the expression.

The first entry on the stack has been done for you.

[4]

(ii) Convert back to its original infix form, the RPN expression:

x w z + y − *

...........................................................................................................................................

...................................................................................................................................... [2]

(iii) Explain one advantage of using RPN for the evaluation of an expression.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [2]

© UCLES 2016 9608/31/O/N/16 [Turn over


306
6

3 A computer operating system (OS) uses paging for memory management.

In paging:

• main memory is divided into equal-size blocks, called page frames


• each process that is executed is divided into blocks of the same size, called pages
• each process has a page table that is used to manage the pages of this process

The following table is the incomplete page table for a process X.

Page Presence Page frame address Additional data


flag
1 1 132
2 1 245
3 1 232
4 0 0
5 1 542
6 0 0

135 0 0

When a particular page of the process is currently in main memory, the Presence flag entry in the
page table is set to 1.

If the page is not currently present in memory, the Presence flag is set to 0.

(a) The page frame address entry for Page 2 is 245.

State what the value 245 could represent.

.............................................................................................................................................. [1]

(b) Process X executes until the next instruction is the first instruction in Page 4. Page 4 is not
currently in main memory.

State a hardware device that could be storing this page.

.............................................................................................................................................. [1]

© UCLES 2016 9608/31/O/N/16


307
7

(c) When an instruction to be accessed is not present in main memory, its page must be loaded
into a page frame. If all page frames are currently in use, the contents of a page frame will be
overwritten with this new page.

The page that is to be replaced is determined by a page replacement algorithm.

One possible algorithm is to replace the page that has been resident in main memory for the
longest time.

(i) Give the additional data that would need to be stored in the page table.

...........................................................................................................................................

..................................................................................................................................... [1]

(ii) Complete the table entries below to show what happens when Page 4 is swapped into
main memory. Assume that Page 5 is the one to be replaced.

In the final column, give an example of the data you have identified in part (c)(i).

Page Presence Page frame address Additional data


flag

4
............... .................... .....................................

[3]

An alternative algorithm is to replace the page that has been used least.

(iii) Give the different additional data that the page table would now need to store.

...........................................................................................................................................

...................................................................................................................................... [1]

(iv) In the following table, complete the missing data to show what happens when Page 3 is
swapped into main memory. Assume that Page 1 is the one to be replaced.

In the final column, give an example of the data you have identified in part (c)(iii).

Page Presence Page frame address Additional data


flag

3
............... .................... .....................................

[3]
© UCLES 2016 9608/31/O/N/16 [Turn over
308
8

(d) Explain why the algorithms given in part (c) may not be the best choice for efficient memory
management.

Longest resident .......................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Least used ................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [4]

4 (a) (i) Complete the truth table for this logic circuit.

X Input Output
A X Y A B
Y 0 0
0 1
1 0
B 1 1

[2]

(ii) State the name given to this logic circuit.

...................................................................................................................................... [1]

(iii) Name the labels usually given to A and B.

Label A ..............................................................................................................................

Label B ..............................................................................................................................

Explain why your answers are more appropriate for the A and B labels.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [4]

© UCLES 2016 9608/31/O/N/16


309
9

(b) (i) Write the Boolean expression corresponding to the following logic circuit:

B
X

...................................................................................................................................... [2]

(ii) Use Boolean algebra to simplify the expression that you gave in part (b)(i).

Show your working.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [3]

© UCLES 2016 9608/31/O/N/16 [Turn over


310
10

5 The TCP/IP protocol suite can be viewed as a stack with four layers.

(a) (i) Complete the stack by inserting the names of the three missing layers.

Transport

[3]

(ii) State how each layer of the stack is implemented.

...................................................................................................................................... [1]

(b) A computer is currently running two processes:

• Process 1 is downloading a web page.


• Process 2 is downloading an email.

(i) Describe two tasks that the Transport layer performs to ensure that the incoming data is
downloaded correctly.

1 .......................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

2 .......................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [4]

(ii) Name a protocol that will be used by Process 1.

...................................................................................................................................... [1]

(iii) Name a protocol that will be used by Process 2.

...................................................................................................................................... [1]

© UCLES 2016 9608/31/O/N/16


311
11

6 (a) The table below gives descriptions of three types of malware.

Description Term
Malware that attaches itself to another program.

Malware that redirects the web browser to a fake website.

Email that encourages the receiver to access a website and


give their banking details.

Complete the table by adding the correct terms. [3]

(b) Ben wants to send a highly confidential email to Mariah so that only she can read it. Plain text
and cipher text will be used in this communication.

(i) Explain the terms plain text and cipher text.

Plain text ............................................................................................................................

...........................................................................................................................................

Cipher text .........................................................................................................................

...................................................................................................................................... [2]

(ii) Explain how the use of asymmetric key cryptography ensures that only Mariah can read
the email.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [4]

© UCLES 2016 9608/31/O/N/16


312

Cambridge International Examinations


Cambridge International Advanced Level

COMPUTER SCIENCE 9608/31


Paper 3 Written Paper October/November 2016
MARK SCHEME
Maximum Mark: 75

Published

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.

Cambridge will not enter into discussions about these mark schemes.

Cambridge is publishing the mark schemes for the October/November 2016 series for most
®
Cambridge IGCSE , Cambridge International A and AS Level components and some Cambridge O Level
components.

® IGCSE is the registered trademark of Cambridge International Examinations.

This document consists of 7 printed pages.

© UCLES 2016 [Turn over


313
Page 2 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 31

1 (a) +2.5
= 010100000000 0010 [3]
Give full marks for correct answer (normalised or not normalised)

= 10.1 [1]
= 0.101 × 22 // evidence of shifting binary point appropriately [1]

[Max 3]

(b) –2.5
101100000000 0010
Give full marks for correct answer

One’s complement of 12-bit mantissa of +2.5 101011111111 – allow f.t. [1]


+1 to get two’s complement 101100000000 [1]

[Max 3]

(c) 3 [3]
Give full marks for correct answer

= 0.011 X 23 // exponent is 3 [1]


= 11.0 // (1/4+1/8) * 8 [1]

[Max 3]

(d) (i) Not normalised [1]

(ii) First two bits should be different for normalised number


// because the number starts with 00 [1]

(e) reduced accuracy [1]


increased range [1]

© UCLES 2016
314
Page 3 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 31

2 (a)
Statement Compilation stage

This stage removes any


comments in the program Lexical analysis
code

1 mark
This stage could be ignored Syntax analysis
for each
correct
This stage checks the line
grammar of the program Code generation
code

This stage produces a


tokenised version of the Optimisation
program code
[4]

(b) (i) A B + [1]


CD–* [1]

(ii) A – [1]
B/4* [1]
CD–/ [1]

(c) (i)

4 3
1
1 1 5 5 2 mark
per ring
2 2 2 2 2 2 4

+ – *

[4]

(ii) x * [1]
(w + z – y) [1]
Order must be correct for both parts

(iii) No need for rules of precedence [1]


No need for brackets [1]
In RPN evaluation of operators is always left to right [1]

[Max 2]

© UCLES 2016
315
Page 4 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 31

3 (a) The 245th page frame from the start of memory


// the 245th page frame from some base address [1]

(b) Flash memory // magnetic disk // hard drive [1]

(c) (i) Time of entry (NOT time in memory) [1]

(ii)
Page Presence Page frame Additional data
Flag address

4 1 542 12:07:34:49 [1 +1 + 1]

(iii) Number of times the page has been accessed [1]

(iv)
Page Presence Page frame Additional data
Flag address

3 1 132 0 [1 +1 + 1]

Accept only zero for ‘additional data’

(d) For example:


Longest resident: page in for lengthy period of time may be being accessed often [1]
… so not a good candidate for being removed [1]

Least used: a page just entered has a low least used value … [1]
so likely to be a candidate for immediately being swapped out [1]

© UCLES 2016
316
Page 5 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 31

4 (a) (i)
Input Output
X Y A B
0 0 0 0 1 mark for each
correct column
0 1 0 1 (A and B)
1 0 0 1
1 1 1 0
[2]

(ii) Half adder [1]

(iii) C // Carry [1]


S // Sum [1]

represents the carry part of the addition of two bits [1]


represents the sum part of the addition of two bits [1]

(b) (i) A. [1]


(A.B + C) [1]

(ii) Allow follow through from (b)(i)

A.(A.B+C)
= A.A.B + A.C
= A.B +A.C
= A.(B+C)

1 mark for each correct simplification line – max 2 [2]


1 mark for A.(B+C) if correct answer to part (b)(i) [1]

© UCLES 2016
317
Page 6 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 31

5 (a) (i)
Application [1]

Transport

Internet [1]

Network / Link [1]

(ii) software / module / program / code [1]

(b) (i) For example:


check packet port … [1]
to identify the application type [1]
check packet destination socket … [1]
so that packet sent to correct application [1]
check incoming packet sequence number … [1]
to ensure data is reassembled in correct order [1]
recalculate checksum of packet … [1]
to ensure integrity of packet [1]
if packet checksum invalid … [1]
send message to have packet retransmitted [1]

[Max 2 tasks]

[Max 4]

(ii) HTTP / HTTPS [1]

(iii) POP3 [1]

© UCLES 2016
318
Page 7 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 31

6 (a)
Description Term

Malware which attaches itself to another


VIRUS [1]
program.

Malware designed to redirect the web


PHARMING [1]
browser to a fake website.

Email that encourages the receiver to


access a website and give their banking PHISHING [1]
details.

(b) (i) Plain text is the original text [1]

Cipher text is the encrypted version of the plain text [1]

(ii) Asymmetric keys means that the key used to encrypt (public key) is different from the
key used to decrypt (private key) [1]
Ben acquires Mariah’s public key [1]
Ben encrypts email … [1]
using Mariah’s public key [1]
Ben sends encrypted email to Mariah [1]
Mariah decrypts email … [1]
Using her private key [1]

[Max 4]

© UCLES 2016
319

Cambridge International Examinations


Cambridge International Advanced Level
* 7 0 9 8 8 8 7 8 6 9 *

COMPUTER SCIENCE 9608/32


Paper 3 Advanced Theory October/November 2016
1 hour 30 minutes
Candidates answer on the Question Paper.
No Additional Materials are required.
No calculators allowed.

READ THESE INSTRUCTIONS FIRST

Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.

Answer all questions.


No marks will be awarded for using brand names of software packages or hardware.

At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.

The maximum number of marks is 75.

This document consists of 12 printed pages.

DC (ST/JG) 116627/3
© UCLES 2016 [Turn over
320
2

1 In a particular computer system, real numbers are stored using floating-point representation with:

• 8 bits for the mantissa


• 8 bits for the exponent
• two’s complement form for both mantissa and exponent

(a) Calculate the floating point representation of + 3.5 in this system. Show your working.

Mantissa Exponent

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [3]

(b) Calculate the floating-point representation of –3.5 in this system. Show your working.

Mantissa Exponent

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [3]

© UCLES 2016 9608/32/O/N/16


321
3

(c) Find the denary value for the following binary floating-point number. Show your working.

Mantissa Exponent

0 1 1 1 0 0 0 0 0 0 0 0 0 1 0 0

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [3]

(d) (i) State whether the floating-point number given in part (c) is normalised or not normalised.

...................................................................................................................................... [1]

(ii) Justify your answer given in part (d)(i).

...........................................................................................................................................

...................................................................................................................................... [1]

(e) Give the binary two’s complement pattern for the negative number with the largest magnitude.

Mantissa Exponent

[2]

© UCLES 2016 9608/32/O/N/16 [Turn over


322
4

2 There are four stages in the compilation of a program written in a high-level language.

(a) Four statements and four compilation stages are shown below.

Draw a line to link each statement to the correct compilation stage.

Statement Compilation stage

This stage can improve the time


taken to execute the statement: Lexical analysis
x = y + 0

This stage produces object


Syntax analysis
code.

This stage makes use of tree


Code generation
data structures.

This stage enters symbols in


Optimisation
the symbol table.

[4]

(b) Write the Reverse Polish Notation (RPN) for the following expression.

P + Q – R / S

.............................................................................................................................................. [2]

© UCLES 2016 9608/32/O/N/16


323
5

(c) An interpreter is executing a program. The program uses the variables a, b, c and d.

The program contains an expression written in infix form. The interpreter converts the infix
expression to RPN. The RPN expression is:

b a * c d a + + -

The interpreter evaluates this RPN expression using a stack.

The current values of the variables are:

a = 2 b = 2 c = 1 d = 3

(i) Show the changing contents of the stack as the interpreter evaluates the expression.

The first entry on the stack has been done for you.

2
[4]

(ii) Convert back to its original infix form, the RPN expression:

b a * c d a + + -

...........................................................................................................................................

...................................................................................................................................... [2]

(iii) One advantage of using RPN is that the evaluation of an expression does not require
rules of precedence.

Explain this statement.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [2]

© UCLES 2016 9608/32/O/N/16 [Turn over


324
6

3 A computer operating system (OS) uses paging for memory management.

In paging:

• main memory is divided into equal-size blocks, called page frames


• each process that is executed is divided into blocks of the same size, called pages
• each process has a page table that is used to manage the pages of this process

The following table is the incomplete page table for a process, Y.

Page Presence Page frame address Additional data


flag
1 1 221
2 1 222
3 0 0
4 0 0
5 1 542
6 0 0

249 0 0

(a) State two facts about Page 5.

1 ................................................................................................................................................

...................................................................................................................................................

2 ................................................................................................................................................

.............................................................................................................................................. [2]

(b) Process Y executes the last instruction in Page 5. This instruction is not a branch instruction.

(i) Explain the problem that now arises in the continued execution of process Y.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [2]
© UCLES 2016 9608/32/O/N/16
325
7

(ii) Explain how interrupts help to solve the problem that you explained in part (b)(i).

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [3]

(c) When the next instruction is not present in main memory, the OS must load its page into a
page frame. If all page frames are currently in use, the OS overwrites the contents of a page
frame with the required page.

The page that is to be replaced is determined by a page replacement algorithm.

One possible algorithm is to replace the page which has been in memory the shortest amount
of time.

(i) Give the additional data that would need to be stored in the page table.

...........................................................................................................................................

...................................................................................................................................... [1]

(ii) Complete the table entry below to show what happens when Page 6 is swapped into
main memory. Include the data you have identified in part (c)(i) in the final column.
Assume that Page 1 is the one to be replaced.

In the final column, give an example of the data you have identified in part (c)(i).

Page Presence Page frame address Additional data


flag

6 …………. ………..…… …………………….……

[3]

© UCLES 2016 9608/32/O/N/16 [Turn over


326
8

Process Y contains instructions that result in the execution of a loop, a very large number of
times. All instructions within the loop are in Page 1.

The loop contains a call to a procedure whose instructions are all in Page 3.

All page frames are currently in use. Page 1 is the page that has been in memory for the
shortest time.

(iii) Explain what happens to Page 1 and Page 3, each time the loop is executed.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [3]

(iv) Name the condition described in part (c)(iii).

...................................................................................................................................... [1]

4 Both clients and servers use the Secure Socket Layer (SSL) protocol and its successor, the
Transport Layer Security (TLS) protocol.

(a) (i) What is a protocol?

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [2]

(ii) Name the client application used in this context.

...................................................................................................................................... [1]

(iii) Name the server used in this context.

...................................................................................................................................... [1]

(iv) Identify two problems that the SSL and TLS protocols can help to overcome.

1 ........................................................................................................................................

2 ................................................................................................................................... [2]
© UCLES 2016 9608/32/O/N/16
327
9

(b) Before any application data is transferred between the client and the server, a handshake
process takes place. Part of this process is to agree the security parameters to be used.

Describe two of these security parameters.

1 ................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

2 ................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [4]

(c) Name two applications of computer systems where it would be appropriate to use the SSL or
TLS protocol. These applications should be different from the ones you named in part (a)(ii)
and part (a)(iii).

1 ................................................................................................................................................

...................................................................................................................................................

2 ................................................................................................................................................

.............................................................................................................................................. [2]

© UCLES 2016 9608/32/O/N/16 [Turn over


328
10

5 (a) (i) A half adder is a logic circuit with the following truth table.

Input Output
X Y A B
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 0

The following logic circuit is constructed.

P X A
J
HALF ADDER
Q Y B

X A
HALF ADDER
R Y B K

Complete the following truth table for this logic circuit.

Input Working space Output


P Q R J K
0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1
[2]

(ii) State the name given to this logic circuit.

...................................................................................................................................... [1]

© UCLES 2016 9608/32/O/N/16


329
11

(iii) Name the labels usually given to J and K.

Label J ..............................................................................................................................

Label K ..............................................................................................................................

Explain why your answers are appropriate labels for these outputs.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [4]

(b) (i) Write down the Boolean expression corresponding to the following logic circuit:

A
B
X

...................................................................................................................................... [2]

(ii) Use Boolean algebra to simplify the expression given in part (b)(i).

Show your working.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [4]

© UCLES 2016 9608/32/O/N/16 [Turn over


330
12

6 A Local Area Network (LAN) consists of four computers, one server and a switch. The LAN uses a
star topology.

(a) Complete the diagram below to show how to connect the devices.

Computer Computer Server


A B

Computer Computer Switch


C D [2]

(b) The LAN uses packets to transfer data between devices.

Three statements are given below.

Tick (✓) to show whether each statement is true or false.

Statement True False

All packets must be routed via the server.


Computer B can read a copy of the packet sent
from the Server to Computer A.
No collisions are possible.
[3]

(c) In the same building as this star network, there is another star network.

(i) Name the device needed to connect the two networks together.

...................................................................................................................................... [1]

(ii) Explain how the device in part (c)(i) decides whether to transfer a packet from one
network to the other.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [2]
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.

© UCLES 2016 9608/32/O/N/16


331

Cambridge International Examinations


Cambridge International Advanced Level

COMPUTER SCIENCE 9608/32


Paper 3 Written Paper October/November 2016
MARK SCHEME
Maximum Mark: 75

Published

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.

Cambridge will not enter into discussions about these mark schemes.

Cambridge is publishing the mark schemes for the October/November 2016 series for most
®
Cambridge IGCSE , Cambridge International A and AS Level components and some Cambridge O Level
components.

® IGCSE is the registered trademark of Cambridge International Examinations.

This document consists of 7 printed pages.

© UCLES 2016 [Turn over


332
Page 2 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 32

1 (a) +3.5
01110000 00000010 [3]
Give full marks for correct answer (normalised or unnormalised)

= 11.1 [1]
= 0.111 × 22 // evidence of shifting binary point appropriately [1]

[Max 3]

(b) –3.5
10010000 00000010 [3]
3 marks for correct answer

One’s complement of 8-bit mantissa for +3.5 10001111 – allow f.t. [1]
+1 to get two’s complement 10010000 [1]

[Max 3]

(c) 14 [3]
3 marks for correct answer

=0.111 X 24 // exponent is 4 [1]


=1110.0 / (1/2 + 1/4 + 1/8) * 16 [1]

[Max 3]

(d) (i) Normalised [1]

(ii) Leftmost two bits are different for normalised representation


// because the pattern starts with 01 [1]

(e)
[1]
1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1
[1]

© UCLES 2016
333
Page 3 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 32

2 (a)
Statement Compilation stage

This stage can improve


the time taken to
Lexical analysis
execute the statement:
x = y + 0

1
This stage produces
Syntax analysis mark for
object code.
each
correct
line
This stage makes use
Code generation
of tree data structures.

This stage enters


symbols in the symbol Optimisation
table.
[4]

(b) P Q + [1]
RS/ – [1]

(c) (i)
2

3 3 5
1
2 1 1 1 1 6 mark
per ring
2 2 4 4 4 4 4 4 –2

* + + –
[4]

(ii) b * a [1]
– (c + d + a) [1]
Order must be correct for both parts

(iii) Rules of precedence means different operators have different priorities // by example
multiply is done before add [1]
In RPN evaluation of operators is left to right // operators are used in the sequence in
which they are read [1]
No need for brackets // infix may require the use of brackets [1]

[Max 2 ]

© UCLES 2016
334
Page 4 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 32

3 (a) The page is present in memory [1]


Loaded at / stored /present in page frame 542 // its memory address is 542 [1]

(b) (i) Next instruction is first instruction in Page 6 [1]


Page 6 is not present in memory [1]
Instruction can only be executed if present in memory [1]
Program cannot continue until Page 6 is loaded [1]

[Max 2]

(ii) When there is an attempt to load an instruction for a page not in memory [1]
A page fault occurs // Page 5 finishes … [1]
this generates an interrupt [1]
ISR code is executed [1]
Causes the OS to load page 6 into memory [1]

[Max 3]

(c) (i) Time of entry (NOT time in memory) [1]

(ii)
Page Presence Page frame address Additional data
Flag

6 1 221 12:07:34:49 [1 + 1 + 1]

(iii) When the procedure call is made – Page 1 is swapped out and Page 3 is swapped in [1]
At the end of the procedure call – Page 3 is swapped out and Page 1 is swapped in [1]
Page 1/3 is always in memory shortest amount of time [1]
The entire sequence is repeated for every iteration [1]

[Max 3]

(iv) Thrashing // continually swapping pages [1]

© UCLES 2016
335
Page 5 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 32

4 (a) (i) A set of rules … [1]


governing communications/transmission of data /sending and receiving data [1]

(ii) For example, (Web) browser / email client [1]

(iii) For example, Web server / email server [1]

(iv) Security //example: for example, alteration of transmitted messages [1]


Privacy // for example, only intended receiver can view data [1]
Authentication // for example, trust in other party [1]

[Max 2]

(b) For example:

which protocol will be used… [1]


there are a number of different versions of the two protocols [1]
session ID … [1]
uniquely identifies a related series of messages between server and client [1]
session type … [1]
reusable or not [1]
encryption method … [1]
public / private keys to be used // asymmetric/ symmetric [1]
authentication method … [1]
use of digital certificates / use of digital signature [1]
compression … [1]
method to be used [1]

[Max 2 parameters]

[Max 4]

(c) For example:

banking [1]
private / secure email [1]
shopping [1]
financial transactions [1]
secure file transfer [1]

[Max 2]

© UCLES 2016
336
Page 6 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 32

5 (a) (i)

Input Output
Working space
P Q R J K
0 0 0 0 0
0 0 1 0 1
1 mark each column
0 1 0 0 1
0 1 1 1 0 If zero marks then
6 or 7 pairs correct – 1 mark
1 0 0 0 1
1 0 1 1 0
1 1 0 1 0
1 1 1 1 1
[2]

(ii) Full adder [1]

(iii) C / Carry [1]


S / Sum [1]
represents the carry part of the addition of three bits [1]
represents the sum part of the addition of three bits [1]

(b) (i) A. [1]


(A+B).C [1]

(ii) Allow follow through from (b)(i)

A. ((A+B).C)
= A.(A.C + B.C)
= A.A.C +A.B.C
= A.C + A.B.C
= A.C (1 + B)
=A.C.1
= A.C

1 mark for each correct simplification line – max 3 [3]


1 mark for A.C if correct answer to part (b)(i) [1]

[4]

© UCLES 2016
337
Page 7 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 32

6 (a)
Computer A Computer B Server 4×
Computer to
Switch
[1]

Server to
Computer C Computer D Switch Switch
[1]

(b)
Statement True False

All packets must be routed via the server. 9 [1]

Computer B can read a copy of the packet


9 [1]
sent from the Server to Computer A.

No collisions are possible. 9 [1]

(c) (i) Router / Switch / Bridge [1]

(ii) Router uses IP addresses in making decisions [1]


Router has routing table [1]
Routing table has entry for associated network ID // routing table has entry for host
address // routing table used to make decision on where to route packet [1]

Switch / Bridge use MAC addresses [1]


MAC address table created [1]
Switch / bridge use MAC address table to make decision on where to route packet [1]

[Max 2]

© UCLES 2016
338

Cambridge International Examinations


Cambridge International Advanced Level

COMPUTER SCIENCE 9608/41


Paper 4 Further Problem-solving and Programming Skills October/November 2016
PRE-RELEASE MATERIAL
This material should be given to the relevant teachers and candidates as soon as it has been received
* 2 8 5 7 7 9 6 9 5 0 *

at the Centre.

READ THESE INSTRUCTIONS FIRST

Candidates should use this material in preparation for the examination. Candidates should attempt the
practical programming tasks using their chosen high-level, procedural programming language.

This document consists of 12 printed pages.

DC (ST) 115878/4
© UCLES 2016 [Turn over
339
2

Teachers and candidates should read this material prior to the November 2016 examination for
9608 Paper 4.

Reminders
The syllabus states:
• there will be questions on the examination paper which do not relate to this pre-release material
• you must choose a high-level programming language from this list:
• Visual Basic (console mode)
• Python
• Pascal / Delphi (console mode)

Note: A mark of zero will be awarded if a programming language other than those listed is used.

The practical skills for Paper 4 build on the practical skills for Paper 2. We therefore recommend that
candidates choose the same high-level programming language for this paper as they did for Paper 2.
This will give candidates the opportunity for extensive practice and allow them to acquire sufficient
expertise.

Questions on the examination paper may ask the candidate to write:


• structured English
• pseudocode
• program code

A program flowchart should be considered as an alternative to pseudocode for the documenting of an


algorithm design.

Candidates should be confident with:


• the presentation of an algorithm using either a program flowchart or pseudocode
• the production of a program flowchart from given pseudocode (or the reverse)

Declaration of variables

The syllabus document shows the syntax expected for a declaration statement in pseudocode.

DECLARE <identifier> : <data type>

If Python is the chosen language, each variable’s identifier (name) and its intended data type must be
documented using a comment statement.

Structured English – Variables

An algorithm in pseudocode uses variables, which should be declared. An algorithm in structured


English does not always use variables. In this case, the candidate needs to use the information given
in the question to complete an identifier table. The table needs to contain an identifier, data type and
description for each variable.

© UCLES 2016 9608/41/PRE/O/N/16


340
3

TASK 1

When writing high-level language programs you are asked to use one of:
• Python
• Visual Basic (console mode)
• Pascal/Delphi (console mode) Key focus: Programming environments

Syllabus section 2.4.1 refers to an Integrated Development Environment (IDE).


Syllabus section 4.3.4 refers to the use of development tools and programming environments.

Make sure you know the name of the programming environment that you use to write programs in your
chosen programming language.

TASK 1.1

Explore the features of your editor that help you to write program code.
When and how does your programming environment report syntax errors?

TASK 1.2

When you write program code, explore debugger features available to you and practise using them to
step through programs and explore the state of the variables after each instruction.

Explore how the debugger can help to find logic errors and run-time errors.

TASK 1.3

Write program code for the following insertion sort algorithm.


Correct any syntax errors.
Then use the debugger to find other types of error.

You will need to write a main program that initialises and populates an array of names to be sorted.
The program then calls the procedure Sort.

PROCEDURE Sort(BYREF Names : ARRAY OF STRING, BYVAL Start : INTEGER,


BYVAL Finish : INTEGER)
FOR ThisPointer ←
Start + 1 TO Finish
ThisName ←
Names[ThisPointer]
Pointer ←
ThisPointer – 1
WHILE Names[Pointer] > ThisValue OR Pointer > 0
Names[Pointer + 1] ←
Names[Pointer]
Pointer ←
Pointer – 1
ENDWHILE
Names[Pointer + 1] ←
ThisName
ENDFOR
ENDPROCEDURE

Decide on some test data. Write down the expected results after each repetition (iteration) of the FOR
loop. You should test your program with several different sets of data. Use the debugger each time to
step through the program.

Extension task
Explore what program libraries are available for your chosen programming language. How can you
make use of a library routine that is not part of the basic set-up of your programming environment?

© UCLES 2016 9608/41/PRE/O/N/16 [Turn over


341
4

TASK 2

The table shows part of the instruction set for a processor which has one general purpose register, the
Accumulator (ACC), and an index register (IX).
Note: These instructions are all referred to in syllabus sections 1.4.3 and 3.6.2.
Instruction
Op Explanation
Operand
code
LDM #n Immediate addressing. Load the number n to ACC
LDD <address> Direct addressing. Load the contents of the given address to ACC
Indirect addressing. The address to be used is at the given address. Load the
LDI <address>
contents of this second address to ACC
Indexed addressing. Form the address from <address> + the contents of the
LDX <address>
index register. Copy the contents of this calculated address to ACC
LDR #n Immediate addressing. Load the number n into IX
STO <address> Store the contents of ACC at the given address
ADD <address> Add the contents of the given address to the ACC
INC <register> Add 1 to the contents of the register (ACC or IX)
DEC <register> Subtract 1 from the contents of the register (ACC or IX)
JMP <address> Jump to the given address
CMP <address> Compare the contents of ACC with the contents of <address>
CMP #n Compare the contents of ACC with number n
JPE <address> Following a compare instruction, jump to <address> if the compare was TRUE
JPN <address> Following a compare instruction, jump to <address> if the compare was FALSE
AND #n Bitwise AND operation of the contents of ACC with the operand
AND <address> Bitwise AND operation of the contents of ACC with the contents of <address>
XOR #n Bitwise XOR operation of the contents of ACC with the operand
XOR <address> Bitwise XOR operation of the contents of ACC with the contents of <address>
OR #n Bitwise OR operation of the contents of ACC with the operand
OR <address> Bitwise OR operation of the contents of ACC with the contents of <address>
IN Key in a character and store its ASCII value in ACC
OUT Output to the screen the character whose ASCII value is stored in ACC
END Return control to the operating system

© UCLES 2016 9608/41/PRE/O/N/16


342
5

Notes:

# denotes immediate addressing


B denotes a binary number, for example B01001010
& denotes a hexadecimal number, for example &4A

Tasks 2.1 to 2.7 all use one of the following two formats for symbolic addressing.

Format Example
<label>: <op code> <operand> START: LDA #0
<label>: <data> NUM1: B01001010

Key focus: Low-level Programming

Write assembly language program code using the instruction set provided on page 4.

Tasks 2.1 to 2.5 show a high-level language construct written in pseudocode.


Each of these tasks consists of writing the assembly language.

© UCLES 2016 9608/41/PRE/O/N/16 [Turn over


343
6

TASK 2.1

X ← A + B
END

Instruction
Label Op Comment
Operand
code
START: // load the content of A into ACC

// add the content of B to content of ACC

// store content of ACC at address X

END // end of program

X:

A: 5

B: 3

© UCLES 2016 9608/41/PRE/O/N/16


344
7

TASK 2.2

IF X = A
THEN
OUTPUT CHR(X) // statements for THEN part
ELSE
A ←
A + 1 // statements for ELSE part
ENDIF
END

Instruction
Label Op Comment
Operand
code
START: // load the content of X into ACC

// compare the content of ACC with content of A

// if not equal (FALSE), jump to ELSE

THEN: // instruction for THEN part start here

JMP ENDIF // jump over the ELSE part

ELSE: // instructions for ELSE part start here

ENDIF: // remainder of program continues from here

END // end of program

A: 65

X: 67

Note: the built-in function CHR(X) returns the character that is represented by the ASCII code held in X.

© UCLES 2016 9608/41/PRE/O/N/16 [Turn over


345
8

TASK 2.3

REPEAT
OUTPUT CHR(X)
X ← X - 1
UNTIL X = A
END

Instruction
Label Op Comment
Operand
code
LOOP: // instructions to be repeated start here

// is content of ACC = content of A ?

// if not equal (FALSE), jump to LOOP

END // end of program

X: 90

A: 65

© UCLES 2016 9608/41/PRE/O/N/16


346
9

TASK 2.4

FOR COUNT ←
1 TO 4
OUTPUT CHARS[COUNT]
ENDFOR
END

Instruction
Label Op Comment
Operand
code
// set ACC to zero

// store content of ACC in COUNT

LOOP: // increment COUNT starts here

// instructions to be repeated start here

// COUNT = 4 ?

// if not equal (FALSE), jump to LOOP

END // end of program

COUNT:

CHARS: 72 // 'H'

69 // 'E'

76 // 'L'

80 // 'P'

© UCLES 2016 9608/41/PRE/O/N/16 [Turn over


347
10

TASK 2.5

WHILE X <> B
OUTPUT CHARS[B]
B ← B + 1
ENDWHILE
END

Instruction
Label Op Comment
Operand
code
LOOP: // load content of X into ACC
// is content of ACC = content of B ?
// if equal (TRUE) jump to ENDWHILE
// instructions to be repeated start here

// jump back to start of loop

END // end of program

X: 4
B: 0
CHARS: 72 // 'H'
69 // 'E'
76 // 'L'
80 // 'P'

© UCLES 2016 9608/41/PRE/O/N/16


348
11

TASK 2.6

Output a string using indirect addressing.

Instruction
Address Op Comment
Operand
code
// use indirect addressing to load contents of
LOOP:
address found at address 100
// output character with ASCII code held in ACC

// load content of address 100

// increment ACC

// store content of ACC at address 100

// is content of ACC = 107 ?

// if not equal (FALSE), jump to LOOP

END // end of program

100 102

101

102 77 // 'M'

103 65 // 'A'

104 84 // 'T'

105 72 // 'H'

106 83 // 'S'

107

© UCLES 2016 9608/41/PRE/O/N/16 [Turn over


349
12

TASK 2.7

Programmers use bitwise operations (AND, OR, XOR) to set or examine specific bits.

Example:

Instruction
Label Op Comment
Operand
code
LOOP: LDD X // load content of X into ACC
// bitwise AND operation on content of ACC and
AND MASK
content of MASK
STO Y // store content of ACC in Y

END // end of program

X: B10101111

Y: // what does the value of Y tell you about X ?

MASK: B00000001

Write simple programs using the different bitwise operations (AND, OR, XOR) and different MASK content.

Identify the operation and MASK bit pattern to:

• set a bit to 1, leaving all other bits unchanged


• set a bit to 0, leaving all other bits unchanged
• test whether a specific bit is 1
• test whether a specific bit is 0

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 International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.

Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.

© UCLES 2016 9608/41/PRE/O/N/16


350

Cambridge International Examinations


Cambridge International Advanced Level
* 8 1 1 8 3 7 8 6 0 3 *

COMPUTER SCIENCE 9608/41


Paper 4 Further Problem-solving and Programming Skills October/November 2016
2 hours
Candidates answer on the Question Paper.
No Additional Materials are required.
No calculators allowed.

READ THESE INSTRUCTIONS FIRST

Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.

Answer all questions.


No marks will be awarded for using brand names of software packages or hardware.

At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.

The maximum number of marks is 75.

This document consists of 16 printed pages.

DC (ST/SW) 115877/3
© UCLES 2016 [Turn over
351
2

1 A user can lock a safety deposit box by inputting a 4-digit code. The user can unlock the box with
the same 4-digit code.

There is a keypad on the door of the safety deposit box. The following diagram shows the keys on
the keypad.

1 2 3

4 5 6

7 8 9

R 0 Enter

Initially, the safety deposit box door is open and the user has not set a code.

The operation of the safety deposit box is as follows:

A) To set a new code the door must be open. The user chooses a 4-digit code and sets it by
pressing the numerical keys on the keypad, followed by the Enter key. Until the user clears
this code, it remains the same. (See point E below)
B) The user can only close the door if the user has set a code.
C) To lock the door, the user closes the door, enters the set code and presses the Enter key.
D) To unlock the door, the user enters the set code. The door then opens automatically.
E) The user clears the code by opening the door and pressing the R key, followed by the Enter
key. The user can then set a new code. (See point A above)

The following state transition table shows the transition from one state to another of the safety
deposit box:

Current state Event Next state


Door open, no code set 4-digit code entered Door open, code set
Door open, code set R entered Door open, no code set
Door open, code set Close door Door closed
Door closed Set code entered Door locked
Door locked Set code entered Door open, code set
Door locked R entered Door locked

© UCLES 2016 9608/41/O/N/16


352
3

(a) Complete the state-transition diagram.

.......................................................
start

............................
Door open
no code set
............................
......................................

...............................................

...............................................

Door closed

............................

............................

...............................................
...............................................
[7]

© UCLES 2016 9608/41/O/N/16 [Turn over


353
4

(b) A company wants to simulate the use of a safety deposit box. It will do this with object-oriented
programming (OOP).

The following diagram shows the design for the class SafetyDepositBox. This includes the
properties and methods.

SafetyDepositBox
Code : STRING // 4 digits
State : STRING // "Open-NoCode", "Open-CodeSet", "Closed"
// or "Locked"
Create() // method to create and initialise an object
// if using Python use __init__
Reset() // clears Code
SetState() // set state to parameter value
// and output new state
SetNewCode() // sets Code to parameter value
// output message and new code
StateChange() // reads keypad and takes appropriate action

Write program code for the following methods.

Programming language ............................................................................................................

(i) Create()

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [3]

(ii) Reset()

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [2]

© UCLES 2016 9608/41/O/N/16


354
5

(iii) SetState()

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [2]

(iv) SetNewCode()

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [2]

(v) The user must enter a 4-digit code.

Write program code for a function Valid(s : STRING)that returns:

• TRUE if the input string s consists of exactly 4 digits


• FALSE otherwise

Programming language .....................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [4]

© UCLES 2016 9608/41/O/N/16 [Turn over


355
6

(vi) Convert the flowchart to program code for the method StateChange(). Use the
properties and methods in the original class definition and the Valid() function from
part (v).

METHOD StateChange

INPUT Chars

Yes Is State = Yes


Is Chars = 'R'? CALL Reset()
"Open-CodeSet"?

No No
CALL SetState("Open-NoCode")

Is Chars = Code? Yes Is State = Yes


CALL SetState("Open-CodeSet")
"Locked"?

No No

Is State = Yes
CALL SetState("Locked")
"Closed"?

No

Is Chars = "" Yes


and State = CALL SetState("Closed")
"Open-CodeSet"?

No

Yes Is State = Yes


Is Chars a valid CALL SetNewCode(Chars)
4-digit code? "Open-NoCode"?

No No
CALL SetState("Open-CodeSet")
OUTPUT "Error – OUTPUT "Error –
code format does not match
incorrect" set code"

ENDMETHOD

© UCLES 2016 9608/41/O/N/16


356
7

Programming language .....................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.....................................................................................................................................[12]

© UCLES 2016 9608/41/O/N/16 [Turn over


357
8

(vii) The company needs to write a program to simulate a safety deposit box. The program
will create an object with identifier ThisSafe, which is an instance of the class
SafetyDepositBox.

The main program design is:

instantiate ThisSafe (create and initialise ThisSafe)


loop forever (continually use ThisSafe)
call StateChange() method
end loop

Write program code for the main program.

Programming language .....................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [4]

© UCLES 2016 9608/41/O/N/16


358
9

(c) It is possible to declare properties and methods as either public or private.

The programmer has modified the class design for SafetyDepositBox as follows:

SafetyDepositBox
PRIVATE
Code : STRING
State : STRING
PUBLIC
Create()
StateChange()
PRIVATE
Reset()
SetState()
SetNewCode()

(i) Describe the effects of declaring the SafetyDepositBox properties as private.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [2]

(ii) Describe the effects of declaring two methods of the class as public and the other three
as private.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [2]

© UCLES 2016 9608/41/O/N/16 [Turn over


359
10

2 Circle the programming language that you have studied:

Visual Basic (console mode) Python Pascal Delphi (console mode)

(a) (i) Name the programming environment you have used when typing in program code.

...........................................................................................................................................

...........................................................................................................................................

List three features of the editor that helped you to write program code.

1 ........................................................................................................................................

...........................................................................................................................................

2 ........................................................................................................................................

...........................................................................................................................................

3 ........................................................................................................................................

...................................................................................................................................... [3]

(ii) Explain when and how your programming environment reports a syntax error.

When .................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

How ...................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [2]

© UCLES 2016 9608/41/O/N/16


360
11

Question 2 continues on page 12.

© UCLES 2016 9608/41/O/N/16 [Turn over


361
12

(iii) The table shows a module definition for BinarySearch in three programming languages.

Study one of the examples. Indicate your choice by circling A, B or C:

A B C

A) Python
01 def BinarySearch(List, Low, High, SearchItem):
02 Index = -1
03 while (Index == -1) AND (Low <= High):
04 Middle = (High + Low) // 2
05 if List[Middle] == SearchItem:
06 Index = Middle
07 elif List[Middle] < SearchItem:
08 Low = Middle + 1
09 else:
10 High = Middle - 1
11 return(Middle)
B) Pascal/Delphi
01 FUNCTION BinarySearch(VAR List : ARRAY OF INTEGER; Low, High,
SearchItem : INTEGER) : INTEGER;
02 VAR Index, Middle : INTEGER;
03 BEGIN
04 Index := -1;
05 WHILE (Index = -1) & (Low <= High) DO
06 BEGIN
07 Middle := (High + Low) DIV 2;
08 IF List[Middle] = SearchItem
09 THEN Index := Middle
10 ELSE IF List[Middle] < SearchItem
11 THEN Low := Middle + 1
12 ELSE High := Middle - 1;
13 END;
14 Result := Middle;
15 END;
C) Visual Basic
01 Function BinarySearch(ByRef List() As Integer, ByVal Low As Integer,
ByVal High As Integer, ByVal SearchItem As Integer) As Integer
02 Dim Index, Middle As Integer
03 Index = -1
04 Do While (Index = -1) & (Low <= High)
05 Middle = (High + Low) \ 2
06 If List(Middle) = SearchItem Then
07 Index = Middle
08 ElseIf List(Middle) < SearchItem Then
09 Low = Middle + 1
10 Else
11 High = Middle - 1
12 End If
13 Loop
14 BinarySearch = Middle
15 End Function

© UCLES 2016 9608/41/O/N/16


362
13

The programming environment reported a syntax error in the BinarySearch code.

State the line number: .......................................................................................................

Write the correct code for this line.

.......................................................................................................................................[2]

(b) (i) State whether programs written in your programming language are compiled or
interpreted.

...........................................................................................................................................

...................................................................................................................................... [1]

(ii) A programmer corrects the syntax error and tests the function. It does not perform as
expected when the search item is not in the list.

State the type of error: .......................................................................................................

Write down the line number where the error occurs.

...........................................................................................................................................

Write the correct code for this line.

.......................................................................................................................................[2]

(iii) State the programming environment you have used when debugging program code.

...........................................................................................................................................

...........................................................................................................................................

Name two debugging features and describe how they are used.

1 ........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

2 ........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [4]

© UCLES 2016 9608/41/O/N/16 [Turn over


363
14

3 The following table shows part of the instruction set for a processor which has one general purpose
register, the Accumulator (ACC), and an index register (IX).

Instruction
Op Explanation
Operand
code
LDM #n Immediate addressing. Load the number n to ACC.
LDD <address> Direct addressing. Load the contents of the given address to ACC.
Indexed addressing. Form the address from <address> + the contents
LDX <address> of the index register. Copy the contents of this calculated address to
ACC.
LDR #n Immediate addressing. Load the number n into IX.
STO <address> Store the contents of ACC at the given address.
INC <register> Add 1 to the contents of the register (ACC or IX).
DEC <register> Subtract 1 from the contents of the register (ACC or IX).
CMP <address> Compare the contents of ACC with the contents of <address>.
CMP #n Compare the contents of ACC with number n.
Following a compare instruction, jump to <address> if the compare
JPE <address>
was True.
Following a compare instruction, jump to <address> if the compare
JPN <address>
was False.
Output to the screen the character whose ASCII value is stored in
OUT
ACC.
END Return control to the operating system.

A programmer is writing a program that outputs a string, first in its original order and then in
reverse order.

The program will use locations starting at address NAME to store the characters in the string. The
location with address MAX stores the number of characters that make up the string.

The programmer has started to write the program in the table opposite. The Comment column
contains descriptions for the missing program instructions.

Complete the program using op codes from the given instruction set.

© UCLES 2016 9608/41/O/N/16


364
15

Op
Label Operand Comment
code
START: // initialise index register to zero

// initialise COUNT to zero

LOOP1: // load character from indexed address NAME

// output character to screen

// increment index register

// increment COUNT starts here

// is COUNT = MAX ?

// if FALSE, jump to LOOP1

REVERSE: // decrement index register

// set ACC to zero

// store in COUNT

LOOP2: // load character from indexed address NAME

// output character to screen

// decrement index register

// increment COUNT starts here

// is COUNT = MAX ?

// if FALSE, jump to LOOP2

// end of program

COUNT:

MAX: 4

NAME: B01000110 // ASCII code in binary for 'F'

B01010010 // ASCII code in binary for 'R'

B01000101 // ASCII code in binary for 'E'

B01000100 // ASCII code in binary for 'D'

[15]
© UCLES 2016 9608/41/O/N/16 [Turn over
365
16

4 Commercial software usually undergoes acceptance testing and integration testing.

Distinguish between the two types of testing by stating:

• who does the testing


• when the testing occurs
• the specific purpose of each type of testing

(i) Acceptance testing

Who ..........................................................................................................................................

...................................................................................................................................................

When ........................................................................................................................................

...................................................................................................................................................

Purpose ....................................................................................................................................

...............................................................................................................................................[3]

(ii) Integration testing

Who ..........................................................................................................................................

...................................................................................................................................................

When ........................................................................................................................................

...................................................................................................................................................

Purpose ....................................................................................................................................

...............................................................................................................................................[3]

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 International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.

Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.

© UCLES 2016 9608/41/O/N/16


366

Cambridge International Examinations


Cambridge International Advanced Level

COMPUTER SCIENCE 9608/41


Paper 4 Written Paper October/November 2016
MARK SCHEME
Maximum Mark: 75

Published

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.

Cambridge will not enter into discussions about these mark schemes.

Cambridge is publishing the mark schemes for the October/November 2016 series for most
®
Cambridge IGCSE , Cambridge International A and AS Level components and some Cambridge O Level
components.

® IGCSE is the registered trademark of Cambridge International Examinations.

This document consists of 12 printed pages.

© UCLES 2016 [Turn over


367
Page 2 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 41

1 (a) 1 mark for both Set code entered correct. 1 mark for each label. [7]

(b) (i) 1 mark per bullet to max 3 [3]


• Method header
• initialising Code to ""
• initialising State to "Open-NoCode"
e.g.

PYTHON:
def __init__(self):
self.__code = ""
self.__state = "Open-NoCode"

PASCAL/DELPHI:
constructor SafetyDepositBox.Create();
begin
Code := '';
State := 'Open-NoCode';
end;

© UCLES 2016
368
Page 3 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 41

VB:
Public Sub New()
Code = ""
State = "Open-NoCode"
End Sub

(ii) 1 mark per bullet to max 2 [2]


• method header
• Setting code to ""
e.g.

PYTHON:
def reset(self):
self.__code = ""

PASCAL/DELPHI:
procedure SafetyDepositBox.Reset();
begin
Code := '';
end;

VB:
Public Sub Reset()
Code = ""
End Sub

(iii) 1 mark per bullet to max 2 [2]


• method header with parameter
• setting state to parameter value
• Outputting state
e.g.

PYTHON:
def SetState(self,NewState):
self.__state = NewState
print(self.__state)

PASCAL/DELPHI:
Procedure SetState(NewState : String);
begin
State := NewState
WriteLn(State)
end;

© UCLES 2016
369
Page 4 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 41

VB: VB:
Public Sub SetState(ByVal Private _State As String
NewState As String) Public Property State() As
State = NewState String
Console.WriteLine(State) Get
End Sub Return _State
End Get
Set(value As String)
_State = value
End Set
End Property
Public Sub SetState()
Console.WriteLine(Me.State)
End Sub

(iv) 1 mark per bullet to max 2 [2]


• setting code to parameter
• Outputting New cost set and code
e.g.

PYTHON:
def SetNewCode(self, NewCode):
self.__code = NewCode
print("New code set: ", self.__code)

PASCAL/DELPHI:
procedure SetNewCode(NewCode : String);
begin
Code := NewCode;
WriteLn('New code set: ', Code)
end;

VB:
Public Sub SetNewCode(NewCode)
Code = NewCode
Console.WriteLine("New code set: " & Code)
End Sub

© UCLES 2016
370
Page 5 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 41

(v) 1 mark per bullet to max 4 [4]


• function header taking string parameter, returns Boolean
• check length of string is 4
• check each character is a digit
• return of correct Boolean value for both cases
e.g

PYTHON:
def __valid(self, s):
digits = ['0','1','2','3','4','5','6','7','8','9']
isValid = False
if (len(s) == 4):
if (s[0] in digits) & (s[1] in digits) & (s[2] in digits) &
(s[3] in digits):
isValid = True
return(isValid)

PASCAL/DELPHI:
function Valid(s : string) : Boolean;
var isValid : Boolean; i : integer;
begin
isValid := False
if Length(s) = 4
then
begin
isValid := True;
For i := 1 to 4 do
if (s[i] < '0') OR (s[i] > '9')
then
isValid := False;
end;
end;

VB: ByVal optional


Public Function valid(ByVal s As String) As Boolean
If s Like "####" Then
Return True
Else
Return False
End If
End Function

© UCLES 2016
371
Page 6 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 41

(vi) 1 mark per bullet to max 12 [12]


• read Chars from keyboard
• check if ‘R’ and state = Open-CodeSet
• call method Reset() & method SetState
• if Chars is the set code:
• check if locked
• set state to Open-CodeSet
• else if closed
• then set state to Locked
• if Chars is empty and State is “Open-CodeSet” then setState to closed
• if Chars is a valid 4-digit code and state is Open-NoCode
• call setNewCode and SetState
• outputting correct error messages for not valid 4-digit and state is not Open-NoCode
e.g.

PYTHON:
def StateChange(self):
Chars = input("Enter code: ")
if Chars == "R":
if self.__state == "Open-CodeSet":
self.reset()
self.SetState("Open-NoCode")
elif Chars == self.__code:
if self.__state == "Locked":
self.SetState("Open-CodeSet")
elif self.__state == "Closed":
self.SetState("Locked")
elif (Chars == "")
& (self.__state == "Open-CodeSet"):
self.SetState("Closed")
elif self.__valid(Chars):
if self.__state == "Open-NoCode":
self.SetNewCode(Chars)
self.SetState("Open-CodeSet")
else:
print("Error - does not match set code")
else:
print("Error - Code format incorrect")

© UCLES 2016
372
Page 7 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 41

PASCAL/DELPHI:
Procedure StateChange();
var Chars : String;
begin
ReadLn(Chars);
If Chars = 'R' Then
If State = 'Open-CodeSet' Then
begin
Reset();
SetState('Open-NoCode');
end
Else
If Chars = Code Then
If state = 'Locked' Then
SetState('Open-CodeSet')
Else
If state = 'Closed' Then
SetState('Locked')
Else
If (Chars = '') AND (State = 'Open-CodeSet') Then
SetState('Closed')
Else
If Valid(Chars) Then
begin
If State == 'Open-NoCode' Then
begin
SetNewCode(Chars);
SetState('Open-CodeSet');
end
else
WriteLn('Error - does not match set code')
end
Else
WriteLn('Error - Code format incorrect');
end;

© UCLES 2016
373
Page 8 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 41

VB:
Public Sub StateChange()
Dim Chars As String
Chars = Console.ReadLine()
If Chars = "R" Then
If State = "Open-CodeSet" Then
Reset()
SetState("Open-NoCode")
End If
ElseIf Chars = Code Then
If state = "Locked" Then
SetState("Open-CodeSet")
ElseIf state = "Closed" Then
SetState("Locked")
End If
ElseIf (Chars = "") AND (State = "Open-CodeSet") Then
SetState("Closed")
ElseIf Valid(Chars) Then
If State == "Open-NoCode" Then
SetNewCode(Chars)
SetState("Open-CodeSet")
Else
Console.WriteLine("Error - does not match set code")
End If
Else
Console.WriteLine("Error - Code format incorrect")
End If
End Sub

(vii) 1 mark per bullet to max 4 [4]


• method header
• Initialising ThisSafe to instance of SafetyDepositBox
• Loop forever
• Call method StateChange on ThisSafe
e.g.

PYTHON:
def main():
ThisSafe = SafetyDepositBox()
while True:
ThisSafe.StateChange()

PASCAL/DELPHI:
var ThisSafe : SafetyDepositBox;
ThisSafe := SafetyDepositBox.Create;
while True do
ThisSafe.StateChange;

© UCLES 2016
374
Page 9 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 41

VB:
Sub Main()
Dim ThisSafe As New SafetyDepositBox()
Do
ThisSafe.StateChange()
Loop
End Sub

(c) (i) 1 mark per bullet to max 2: [2]


• The attributes can only be accessed in the class
• Properties are needed to get/set the data // It provides/uses encapsulation
• Increase security/integrity of attributes

(ii) 1 mark per bullet [2]


• The public methods can be called anywhere in the main program // Public methods
can be inherited by sub-classes
• The private methods can only be called within the class definition // cannot be called
outside the class definition // Private methods cannot be inherited by sub-classes

2 (a) (i) 1 mark per feature to max 3 [3]


e.g.
• auto-indent
• auto-complete / by example
• colour-coded keywords/ strings/ comments/ built-in functions/ user-defined function
names
• pop-up help
• can set indent width
• expand/collapse subroutines/code
• block highlighting
incorrect syntax highlighting/underlining //dynamic syntax checker

(ii) Read and mark the answer as one paragraph. Mark a 'how' and a 'when' anywhere in
the answer. [2]
1 mark for when, 1 mark for how.
e.g.
When:
• the error has been typed
• when the program is being run/compiled/interpreted
How:
• highlights/underlines
displays error message/pop-up

(iii)
A B C

Line 3 Line 5 Line 4 [1]

while (Index == -1) WHILE (Index = -1) DO WHILE (Index = -


& (Low <= High): AND (Low <= High) 1) AND (Low <= [1]
DO High)

© UCLES 2016
375
Page 10 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 41

(b) (i) Python: compiled/interpreted [1]


VB.NET: compiled
Pascal: compiled/interpreted
Delphi: compiled/interpreted

(ii)
Logic error Logic error Logic error [1]

11 return(Index) 14 Result := Index; 14 BinarySearch = Index [1]

(iii) 1 mark for each name, 1 for each description [4]

• breakpoint
• a point where the program can be halted to see if the program works at this point

• stepping / step through


• executes one statement at a time and then pauses to see the effect of each
statement

• variable watch window


• observe how variables changed during execution

© UCLES 2016
376
Page 11 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 41

3
START: LDR #0 // initialise index register to zero [1]
LDM #0 // initialise COUNT to zero
[1]
STO COUNT
// load character from indexed address
LOOP1: LDX NAME
NAME [1]

OUT // output character to screen [1]


INC IX // increment index register [1]
LDD COUNT // increment COUNT starts here
INC ACC [1]
STO COUNT
CMP MAX // is COUNT = MAX? [1]
JPN LOOP1 // if FALSE, jump to LOOP1 [1]
REVERSE: DEC IX // decrement index register [1]
LDM #0 // set ACC to zero
[1]
STO COUNT // store in COUNT
// load character from indexed address
LOOP2: LDX NAME
NAME [1]
OUT // output character to screen
DEC IX // decrement index register [1]
LDD COUNT // increment COUNT starts here
INC ACC // [1]
STO COUNT //
CMP MAX // is COUNT = MAX?
[1]
JPN LOOP2 // if FALSE, jump to LOOP2
END // end of program [1]
COUNT:
MAX: 4
NAME: B01000110 // ASCII code in binary for 'F'
B01010010 // ASCII code in binary for 'R'
B01000101 // ASCII code in binary for 'E'
B01000100 // ASCII code in binary for 'D'
[Max 15]

© UCLES 2016
377
Page 12 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 41

4
Acceptance testing Integration testing

Who The end user // user of the The programmer / in-house testers [1] +
software [1]

When When the software is When the separate modules have been [1] +
finished/ when it is installed written and tested [1]

Purpose To ensure the software is To ensure the modules work together as [1] +
what the customer ordered expected [1]
// to check that the software
meets the user requirements

© UCLES 2016
378

Cambridge International Examinations


Cambridge International Advanced Level

COMPUTER SCIENCE 9608/42


Paper 4 Further Problem-solving and Programming Skills October/November 2016
PRE-RELEASE MATERIAL
This material should be given to the relevant teachers and candidates as soon as it has been received
* 4 1 9 3 8 6 1 8 7 5 *

at the Centre.

READ THESE INSTRUCTIONS FIRST

Candidates should use this material in preparation for the examination. Candidates should attempt the
practical programming tasks using their chosen high-level, procedural programming language.

This document consists of 12 printed pages.

DC (ST) 128071
© UCLES 2016 [Turn over
379
2

Teachers and candidates should read this material prior to the November 2016 examination for
9608 Paper 4.

Reminders
The syllabus states:
• there will be questions on the examination paper which do not relate to this pre-release material
• you must choose a high-level programming language from this list:
• Visual Basic (console mode)
• Python
• Pascal / Delphi (console mode)

Note: A mark of zero will be awarded if a programming language other than those listed is used.

The practical skills for Paper 4 build on the practical skills for Paper 2. We therefore recommend that
candidates choose the same high-level programming language for this paper as they did for Paper 2.
This will give candidates the opportunity for extensive practice and allow them to acquire sufficient
expertise.

Questions on the examination paper may ask the candidate to write:


• structured English
• pseudocode
• program code

A program flowchart should be considered as an alternative to pseudocode for the documenting of an


algorithm design.

Candidates should be confident with:


• the presentation of an algorithm using either a program flowchart or pseudocode
• the production of a program flowchart from given pseudocode (or the reverse)

Declaration of variables

The syllabus document shows the syntax expected for a declaration statement in pseudocode.

DECLARE <identifier> : <data type>

If Python is the chosen language, each variable’s identifier (name) and its intended data type must be
documented using a comment statement.

Structured English – Variables

An algorithm in pseudocode uses variables, which should be declared. An algorithm in structured


English does not always use variables. In this case, the candidate needs to use the information given
in the question to complete an identifier table. The table needs to contain an identifier, data type and
description for each variable.

© UCLES 2016 9608/42/PRE/O/N/16


380
3

TASK 1

When writing high-level language programs you are asked to use one of:
• Python
• Visual Basic (console mode)
• Pascal/Delphi (console mode) Key focus: Programming environments

Syllabus section 2.4.1 refers to an Integrated Development Environment (IDE).


Syllabus section 4.3.4 refers to the use of development tools and programming environments.

Make sure you know the name of the programming environment that you use to write programs in your
chosen programming language.

TASK 1.1

Explore the features of your editor that help you to write program code.
When and how does your programming environment report syntax errors?

TASK 1.2

When you write program code, explore debugger features available to you and practise using them to
step through programs and explore the state of the variables after each instruction.

Explore how the debugger can help to find logic errors and run-time errors.

TASK 1.3

Write program code for the following insertion sort algorithm.


Correct any syntax errors.
Then use the debugger to find other types of error.

You will need to write a main program that initialises and populates an array of names to be sorted.
The program then calls the procedure Sort.

PROCEDURE Sort(BYREF Names : ARRAY OF STRING, BYVAL Start : INTEGER,


BYVAL Finish : INTEGER)
FOR ThisPointer ←
Start + 1 TO Finish
ThisName ←
Names[ThisPointer]
Pointer ←
ThisPointer – 1
WHILE Names[Pointer] > ThisValue OR Pointer > 0
Names[Pointer + 1] ←
Names[Pointer]
Pointer ←
Pointer – 1
ENDWHILE
Names[Pointer + 1] ←
ThisName
ENDFOR
ENDPROCEDURE

Decide on some test data. Write down the expected results after each repetition (iteration) of the FOR
loop. You should test your program with several different sets of data. Use the debugger each time to
step through the program.

Extension task
Explore what program libraries are available for your chosen programming language. How can you
make use of a library routine that is not part of the basic set-up of your programming environment?

© UCLES 2016 9608/42/PRE/O/N/16 [Turn over


381
4

TASK 2

The table shows part of the instruction set for a processor which has one general purpose register, the
Accumulator (ACC), and an index register (IX).
Note: These instructions are all referred to in syllabus sections 1.4.3 and 3.6.2.
Instruction
Op Explanation
Operand
code
LDM #n Immediate addressing. Load the number n to ACC
LDD <address> Direct addressing. Load the contents of the given address to ACC
Indirect addressing. The address to be used is at the given address. Load the
LDI <address>
contents of this second address to ACC
Indexed addressing. Form the address from <address> + the contents of the
LDX <address>
index register. Copy the contents of this calculated address to ACC
LDR #n Immediate addressing. Load the number n into IX
STO <address> Store the contents of ACC at the given address
ADD <address> Add the contents of the given address to the ACC
INC <register> Add 1 to the contents of the register (ACC or IX)
DEC <register> Subtract 1 from the contents of the register (ACC or IX)
JMP <address> Jump to the given address
CMP <address> Compare the contents of ACC with the contents of <address>
CMP #n Compare the contents of ACC with number n
JPE <address> Following a compare instruction, jump to <address> if the compare was TRUE
JPN <address> Following a compare instruction, jump to <address> if the compare was FALSE
AND #n Bitwise AND operation of the contents of ACC with the operand
AND <address> Bitwise AND operation of the contents of ACC with the contents of <address>
XOR #n Bitwise XOR operation of the contents of ACC with the operand
XOR <address> Bitwise XOR operation of the contents of ACC with the contents of <address>
OR #n Bitwise OR operation of the contents of ACC with the operand
OR <address> Bitwise OR operation of the contents of ACC with the contents of <address>
IN Key in a character and store its ASCII value in ACC
OUT Output to the screen the character whose ASCII value is stored in ACC
END Return control to the operating system

© UCLES 2016 9608/42/PRE/O/N/16


382
5

Notes:

# denotes immediate addressing


B denotes a binary number, for example B01001010
& denotes a hexadecimal number, for example &4A

Tasks 2.1 to 2.7 all use one of the following two formats for symbolic addressing.

Format Example
<label>: <op code> <operand> START: LDA #0
<label>: <data> NUM1: B01001010

Key focus: Low-level Programming

Write assembly language program code using the instruction set provided on page 4.

Tasks 2.1 to 2.5 show a high-level language construct written in pseudocode.


Each of these tasks consists of writing the assembly language.

© UCLES 2016 9608/42/PRE/O/N/16 [Turn over


383
6

TASK 2.1

X ← A + B
END

Instruction
Label Op Comment
Operand
code
START: // load the content of A into ACC

// add the content of B to content of ACC

// store content of ACC at address X

END // end of program

X:

A: 5

B: 3

© UCLES 2016 9608/42/PRE/O/N/16


384
7

TASK 2.2

IF X = A
THEN
OUTPUT CHR(X) // statements for THEN part
ELSE
A ←
A + 1 // statements for ELSE part
ENDIF
END

Instruction
Label Op Comment
Operand
code
START: // load the content of X into ACC

// compare the content of ACC with content of A

// if not equal (FALSE), jump to ELSE

THEN: // instruction for THEN part start here

JMP ENDIF // jump over the ELSE part

ELSE: // instructions for ELSE part start here

ENDIF: // remainder of program continues from here

END // end of program

A: 65

X: 67

Note: the built-in function CHR(X) returns the character that is represented by the ASCII code held in X.

© UCLES 2016 9608/42/PRE/O/N/16 [Turn over


385
8

TASK 2.3

REPEAT
OUTPUT CHR(X)
X ← X - 1
UNTIL X = A
END

Instruction
Label Op Comment
Operand
code
LOOP: // instructions to be repeated start here

// is content of ACC = content of A ?

// if not equal (FALSE), jump to LOOP

END // end of program

X: 90

A: 65

© UCLES 2016 9608/42/PRE/O/N/16


386
9

TASK 2.4

FOR COUNT ←
1 TO 4
OUTPUT CHARS[COUNT]
ENDFOR
END

Instruction
Label Op Comment
Operand
code
// set ACC to zero

// store content of ACC in COUNT

LOOP: // increment COUNT starts here

// instructions to be repeated start here

// COUNT = 4 ?

// if not equal (FALSE), jump to LOOP

END // end of program

COUNT:

CHARS: 72 // 'H'

69 // 'E'

76 // 'L'

80 // 'P'

© UCLES 2016 9608/42/PRE/O/N/16 [Turn over


387
10

TASK 2.5

WHILE X <> B
OUTPUT CHARS[B]
B ← B + 1
ENDWHILE
END

Instruction
Label Op Comment
Operand
code
LOOP: // load content of X into ACC
// is content of ACC = content of B ?
// if equal (TRUE) jump to ENDWHILE
// instructions to be repeated start here

// jump back to start of loop

END // end of program

X: 4
B: 0
CHARS: 72 // 'H'
69 // 'E'
76 // 'L'
80 // 'P'

© UCLES 2016 9608/42/PRE/O/N/16


388
11

TASK 2.6

Output a string using indirect addressing.

Instruction
Address Op Comment
Operand
code
// use indirect addressing to load contents of
LOOP:
address found at address 100
// output character with ASCII code held in ACC

// load content of address 100

// increment ACC

// store content of ACC at address 100

// is content of ACC = 107 ?

// if not equal (FALSE), jump to LOOP

END // end of program

100 102

101

102 77 // 'M'

103 65 // 'A'

104 84 // 'T'

105 72 // 'H'

106 83 // 'S'

107

© UCLES 2016 9608/42/PRE/O/N/16 [Turn over


389
12

TASK 2.7

Programmers use bitwise operations (AND, OR, XOR) to set or examine specific bits.

Example:

Instruction
Label Op Comment
Operand
code
LOOP: LDD X // load content of X into ACC
// bitwise AND operation on content of ACC and
AND MASK
content of MASK
STO Y // store content of ACC in Y

END // end of program

X: B10101111

Y: // what does the value of Y tell you about X ?

MASK: B00000001

Write simple programs using the different bitwise operations (AND, OR, XOR) and different MASK content.

Identify the operation and MASK bit pattern to:

• set a bit to 1, leaving all other bits unchanged


• set a bit to 0, leaving all other bits unchanged
• test whether a specific bit is 1
• test whether a specific bit is 0

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 International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.

Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.

© UCLES 2016 9608/42/PRE/O/N/16


390

Cambridge International Examinations


Cambridge International Advanced Level
* 4 5 3 0 7 7 3 2 0 8 *

COMPUTER SCIENCE 9608/42


Paper 4 Further Problem-solving and Programming Skills October/November 2016
2 hours
Candidates answer on the Question Paper.
No Additional Materials are required.
No calculators allowed.

READ THESE INSTRUCTIONS FIRST

Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.

Answer all questions.


No marks will be awarded for using brand names of software packages or hardware.

At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.

The maximum number of marks is 75.

This document consists of 17 printed pages and 3 blank pages.

DC (LEG/SW) 115870/4
© UCLES 2016 [Turn over
391
2

1 The ticket machine in the following diagram accepts the following coins: 10, 20, 50 and 100 cents.

The ticket machine has:

• a slot to insert coins


• a tray to return coins
• a ticket dispenser
• two buttons:

• button A (Accept)
• button C (Cancel)

$
Coin Slot

&

Coin
return Ticket dispenser
tray

When the user has inserted as many coins as required, they press button A to print the ticket.

To cancel the transaction, the user can press button C. This makes the machine return the coins.

Invalid coins have no effect.

© UCLES 2016 9608/42/O/N/16


392
3

The following state transition table shows the transition from one state to another of the ticket
machine:

Current state Event Next state


Idle Coin inserted Counting
Counting Coin inserted Counting
Counting Button C pressed Cancelled
Cancelled Coins returned Idle
Counting Button A pressed Accepted
Accepted Ticket printed Idle

(a) Complete the state-transition diagram.

start
Coin inserted
.......................................................

............................ ............................

Cancelled
Coins returned
.......................................................

.......................................................
.......................................................

............................

[7]

© UCLES 2016 9608/42/O/N/16 [Turn over


393
4

(b) A company wants to simulate the use of a ticket machine. It will do this with object-oriented
programming (OOP).

The following diagram shows the design for the class TicketMachine. This includes its
attributes and methods.

TicketMachine
Amount : INTEGER // total value of coins inserted in cents
State : STRING // "Idle", "Counting", "Cancelled"
// or "Accepted"
Create() // method to create and initialise an object
// if using Python use __init__
SetState() // set state to parameter value
// and output new state
StateChange() // insert coin or press button,
// then take appropriate action
CoinInserted() // parameter is a string
// change parameter to integer
// and add coin value to Amount
ReturnCoins() // output Amount, then set Amount to zero
PrintTicket() // print ticket, then set Amount to zero

Write program code for the following methods.

Programming language ............................................................................................................

(i) Create()

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

(ii) SetState()

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

© UCLES 2016 9608/42/O/N/16


394
5

(iii) ReturnCoins()

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [2]

(iv) Each coin inserted must be one of the following: 10, 20, 50 or 100 cents.

Write program code for a function ValidCoin(s : STRING) that returns:

• TRUE if the input string is one of "10", "20", "50" or "100"


• FALSE otherwise

Programming language .....................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

(v) Write program code for the method CoinInserted()

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

© UCLES 2016 9608/42/O/N/16 [Turn over


395
6

(vi) Convert the flowchart to program code for the method StateChange().
Use the attributes and methods in the original class definition and the ValidCoin()
function from part (iv).

METHOD StateChange

INPUT NewInput

Yes Is State = Yes


Is NewInput = 'C'? CALL SetState("Cancelled")
"Counting"?

No
CALL ReturnCoins()
No

Is NewInput = 'A'? Yes Yes OUTPUT "No


Is Amount = 0?
coins inserted"

No No

CALL SetState("Accepted") CALL PrintTicket()

Is NewInput Yes
CALL CoinInserted(NewInput)
a valid
coin?
No
CALL SetState("Counting") CALL SetState("Idle")

OUTPUT "Error –
not a valid
coin"

ENDMETHOD

© UCLES 2016 9608/42/O/N/16


396
7

Programming language .....................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.....................................................................................................................................[12]
© UCLES 2016 9608/42/O/N/16 [Turn over
397
8

(vii) The company needs to write a program to simulate a parking meter. The program
will create an object with identifier ParkingMeter, which is an instance of the class
TicketMachine.

The main program design is:

instantiate ParkingMeter (create and initialise ParkingMeter)


loop forever (continually use ParkingMeter)
call StateChange() method
end loop

Write program code for the main program.

Programming language .....................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[4]

© UCLES 2016 9608/42/O/N/16


398
9

(c) It is possible to declare attributes and methods as either public or private.

A programmer has modified the class design for TicketMachine as follows.

TicketMachine
PRIVATE
Amount : INTEGER
State : STRING
PUBLIC
Create()
StateChange()
PRIVATE
SetState()
CoinInserted()
ReturnCoins()
PrintTicket()

(i) Describe the effects of declaring the TicketMachine attributes as private.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(ii) Describe the effects of declaring two methods of the class as public and the other four as
private.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

© UCLES 2016 9608/42/O/N/16 [Turn over


399
10

2 Commercial software usually undergoes alpha testing and beta testing.

Distinguish between the two types of testing by stating:

• who does the testing


• when the testing occurs
• the specific purpose of each type of testing

(i) Alpha testing

Who ...................................................................................................................................

...........................................................................................................................................

When .................................................................................................................................

...........................................................................................................................................

Purpose .............................................................................................................................

.......................................................................................................................................[3]

(ii) Beta testing

Who ...................................................................................................................................

...........................................................................................................................................

When .................................................................................................................................

...........................................................................................................................................

Purpose .............................................................................................................................

.......................................................................................................................................[3]

3 (a) The numerical difference between the ASCII code of an upper case letter and the ASCII code
of its lower case equivalent is 32 denary (3210).

For example, 'F' has ASCII code 70 and 'f' has ASCII code 102.

Bit number
7 6 5 4 3 2 1 0
ASCII code ASCII code in binary
70 0 1 0 0 0 1 1 0

102 0 1 1 0 0 1 1 0

The bit patterns differ only at bit number 5. This bit is 1 if the letter is lower case and 0 if the
letter is upper case.

© UCLES 2016 9608/42/O/N/16


400
11

(i) A program needs a mask to ensure that a letter is in upper case.

Write the binary pattern of the mask in the space provided in the table below.

Bit number
7 6 5 4 3 2 1 0
ASCII code ASCII code in binary
70 0 1 0 0 0 1 1 0

102 0 1 1 0 0 1 1 0

Mask

Give the bit-wise operation that needs to be performed using the mask and the
ASCII code.

.......................................................................................................................................[2]

(ii) A program needs a mask to ensure that a letter is in lower case.

Write the binary pattern of the mask in the space provided in the table below.

Bit number
7 6 5 4 3 2 1 0
ASCII code ASCII code in binary
70 0 1 0 0 0 1 1 0

102 0 1 1 0 0 1 1 0

Mask

Give the bit-wise operation that needs to be performed using the mask and the
ASCII code.

.......................................................................................................................................[2]

© UCLES 2016 9608/42/O/N/16 [Turn over


401
12

The following table shows part of the instruction set for a processor which has one general
purpose register, the Accumulator (ACC), and an index register (IX).

Instruction
Op Operand Explanation
code
LDM #n Immediate addressing. Load the number n to ACC.
Direct addressing. Load the contents of the given address to
LDD <address>
ACC.
Indexed addressing. Form the address from <address> +
LDX <address> the contents of the index register. Copy the contents of this
calculated address to ACC.
LDR #n Immediate addressing. Load the number n into IX.
STO <address> Store the contents of ACC at the given address.
INC <register> Add 1 to the contents of the register (ACC or IX).
CMP <address> Compare the contents of ACC with the contents of <address>.
CMP #n Compare the contents of ACC with number n.
Following a compare instruction, jump to <address> if the
JPE <address>
compare was True.
Following a compare instruction, jump to <address> if the
JPN <address>
compare was False.
Bitwise AND operation of the contents of ACC with the
AND #n
operand.
Bitwise AND operation of the contents of ACC with the
AND <address>
contents of <address>.
Bitwise XOR operation of the contents of ACC with the
XOR #n
operand.
Bitwise XOR operation of the contents of ACC with the
XOR <address>
contents of <address>.
OR #n Bitwise OR operation of the contents of ACC with the operand.
Bitwise OR operation of the contents of ACC with the contents
OR <address>
of <address>.
Output to the screen the character whose ASCII value is
OUT
stored in ACC.
END Return control to the operating system.

A programmer is writing a program that will output the first character of a string in upper case and
the remaining characters of the string in lower case.

The program will use locations from address WORD onwards to store the characters in the string.
The location with address LENGTH stores the number of characters that make up the string.

© UCLES 2016 9608/42/O/N/16


402
13

The programmer has started to write the program in the following table. The comment column
contains descriptions for the missing program instructions.

(b) Complete the program using op codes from the given instruction set.

Op
Label Operand Comment
code
START: // initialise index register to zero
// get first character of WORD
// ensure it is in upper case using MASK1
// output character to screen
// increment index register
// load 1 into ACC
// store in COUNT
LOOP: // load next character from indexed address WORD
// make lower case using MASK2
// output character to screen
// increment COUNT starts here

// is COUNT = LENGTH ?
// if FALSE, jump to LOOP
// end of program
COUNT:
MASK1: // bit pattern for upper case
MASK2: // bit pattern for lower case
LENGTH: 4
WORD: B01100110 // ASCII code in binary for 'f'
B01110010 // ASCII code in binary for 'r'
B01000101 // ASCII code in binary for 'E'
B01000100 // ASCII code in binary for 'D'
[12]

© UCLES 2016 9608/42/O/N/16 [Turn over


403
14

Question 4 begins on page 15.

© UCLES 2016 9608/42/O/N/16


404
15

4 Circle the programming language that you have studied:

Visual Basic (console mode) Python Pascal Delphi (console mode)

(a) (i) Name the programming environment you have used when typing in program code.

...........................................................................................................................................

...........................................................................................................................................

List three features of the editor that helped you to write program code.

1 .........................................................................................................................................

...........................................................................................................................................

2 .........................................................................................................................................

...........................................................................................................................................

3 .........................................................................................................................................

.......................................................................................................................................[3]

(ii) Explain when and how your programming environment reports a syntax error.

When .................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

How ...................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

© UCLES 2016 9608/42/O/N/16 [Turn over


405
16

(iii) The table shows a module definition for BubbleSort in three programming languages.

Study one of the examples. Indicate your choice by circling A, B or C:

A B C

A) Python
01 def BubbleSort(SList, Max):
02 NoMoreSwaps = False
03 while NoMoreSwaps == False:
04 NoMoreSwaps = True
05 for i in (Max - 1):
06 if SList[i] > SList[i + 1]:
07 NoMoreSwaps = True
08 Temp = SList[i]
09 SList[i] = SList[i + 1]
10 SList[i + 1] = Temp
B) Pascal/Delphi
01 PROCEDURE BubbleSort(VAR SList : ARRAY OF INTEGER; Max : INTEGER);
02 VAR NoMoreSwaps : BOOLEAN; i, Temp : INTEGER;
03 BEGIN
04 REPEAT
05 NoMoreSwaps := TRUE;
06 FOR i := 1 TO (Max – 1)
07 IF SList[i] > SList[i + 1]
08 THEN
09 BEGIN
10 NoMoreSwaps := TRUE;
11 Temp := SList[i];
12 SList[i] := SList[i + 1];
13 SList[i + 1] := Temp;
14 END;
15 UNTIL NoMoreSwaps;
16 END;
C) Visual Basic
01 Sub BubbleSort(ByRef SList() As Integer, ByVal Max As Integer)
02 Dim NoMoreSwaps As Boolean, i, Temp As Integer
03 Do
04 NoMoreSwaps = True
05 For i : 0 To (Max – 1)
06 If SList(i) > SList(i + 1) Then
07 NoMoreSwaps = True
08 Temp = SList(i)
09 SList(i) = SList(i + 1)
10 SList(i + 1) = Temp
11 End If
12 Next
13 Loop Until (NoMoreSwaps = True)
14 End Sub

© UCLES 2016 9608/42/O/N/16


406
17

The programming environment reported a syntax error in the BubbleSort code.

State the line number ........................................................................................................................

Write the correct code for this line.

...............................................................................................................................................[2]

(b) (i) State whether programs written in your programming language are compiled or
interpreted.

...........................................................................................................................................

.......................................................................................................................................[1]

(ii) A programmer corrects the syntax error and tests the function. It does not perform as
expected. The items are not fully in order.

State the type of error .......................................................................................................

Write the line number where the error occurs.

...........................................................................................................................................

Write the correct code for this line.

.......................................................................................................................................[2]

(iii) State the programming environment you have used when debugging program code.

...........................................................................................................................................

Name two debugging features and describe how they are used.

1 ........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

2 ........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[4]

© UCLES 2016 9608/42/O/N/16


407

Cambridge International Examinations


Cambridge International Advanced Level

COMPUTER SCIENCE 9608/42


Paper 4 Written Paper October/November 2016
MARK SCHEME
Maximum Mark: 75

Published

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.

Cambridge will not enter into discussions about these mark schemes.

Cambridge is publishing the mark schemes for the October/November 2016 series for most
®
Cambridge IGCSE , Cambridge International A and AS Level components and some Cambridge O Level
components.

® IGCSE is the registered trademark of Cambridge International Examinations.

This document consists of 13 printed pages.

© UCLES 2016 [Turn over


408
Page 2 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 42

1 (a) [7]

1 mark for each label

© UCLES 2016
409
Page 3 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 42

(b) (i) 1 mark per bullet to max 3: [3]


• method header and close
• initialising amount to 0
• initialising state to “Idle”

e.g.

PYTHON:
def __init__(self):
self.__amount = 0
self.__state = "Idle"

PASCAL/DELPHI:
constructor TicketMachine.Create();
begin
Amount := 0;
State := 'Idle';
end;

VB: VB:
Public Sub New() Public Sub Create()
Amount = 0 Amount = 0
State = "Idle" state = “Idle”
End Sub End Sub

(ii) 1 mark per bullet to max 2: [2]


• method header, close with parameter
• setting state to parameter value
• outputting state

e.g.

PYTHON:
def SetState(self, NewState):
self.__State = NewState
print(self.__State)

PASCAL/DELPHI:
procedure TicketMachine.SetState(NewState : string);
begin
State := NewState;
Writeln(State);
end;

© UCLES 2016
410
Page 4 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 42

VB: VB:
Public Sub SetState(NewState As Private _State As String
String) Public Property State() As
Me.State = NewState String
Console.WriteLine(Me.State) Get
End Sub Return _State
End Get
Set(value As String)
_State = value
End Set
End Property
Public Sub SetState()
Console.WriteLine(Me.State)
End Sub

(iii) 1 mark per bullet to max 2: [2]


• output Amount
• set amount to zero

e.g.

PYTHON:
def ReturnCoins(self):
print(self.__Amount)
self.__Amount = 0

PASCAL/DELPHI:
procedure TicketMachine.ReturnCoins();
begin
Writeln(Amount);
Amount := 0;
end;

VB:
Public Sub ReturnCoins()
Console.WriteLine(Me.Amount)
Me.Amount = 0
End Sub

© UCLES 2016
411
Page 5 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 42

(iv) 1 mark per bullet to max 3: [3]


• function header, take string as parameter, return Boolean
• check the parameter is a valid coin
• return of value for both cases

e.g.

PYTHON:
def __validCoin(self, s):
coins = ['10','20','50','100']
if s in coins:
isValid = True
else:
isValid = False
return(isValid)

PASCAL/DELPHI:
function TicketMachine.ValidCoin(s : string) : boolean;
begin
if ((s = '10') or (s = '20') or (s = '50') or (s = '100'))
then
ValidCoin:= True;
else
ValidCoin := False;
end;

VB:
Public Function ValidCoin(ByVal s As String) As Boolean
If s = “10” or s = “20” or s = “50” or s = “100” Then
ValidCoin = True
Else
ValidCoin = False
End If
End Sub

© UCLES 2016
412
Page 6 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 42

(v) 1 mark per bullet to max 2 [2]


• Cast parameter as integer
• Add value to amount

e.g.

PYTHON:
def coinInserted(self, s):
coinValue = int(s)
self.__amount = self.__amount + coinValue

PASCAL/DELPHI:
procedure TicketMachine.CoinInserted(s : string);
var
CoinValue, Code : integer;
begin
Val(s, CoinValue, Code);
Amount := Amount + CoinValue;
end;

VB:
Public Sub CoinInserted(ByVal S As String)
CoinValue = INT(s)
Me.Amount = Me.Amount + CoinValue
End Sub

© UCLES 2016
413
Page 7 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 42

(vi) 1 mark per bullet to max 12 [12]


• read NewInput from keyboard
• check if input ‘C’ and state = Counting
o then set state to cancelled
o call method returnCoins() and set state to Idle
• check if input ‘A’
o then check if amount = 0 then output no coins
o else set state to Accepted
o call PrintTicket method and Set state to Idle
• else if input is a valid coin
o call CoinInserted method with NewInput as parameter
o set state to Counting
o error message if not a valid coin

e.g.

PYTHON:
def stateChange(self):
newInput = input("Insert coin: ")
if newInput == "C":
if self.__state == "Counting":
self.setState("Cancelled")
self.returnCoins()
self.setState("Idle")
elif newInput == "A":
if self.__amount == 0:
print("no coins inserted")
else:
self.setState("Accepted")
self.__PrintTicket()
self.setState("Idle")
elif self.__validCoin(newInput):
self.coinInserted(newInput)
self.setState("Counting")
else:
print("Error - not a valid coin")

PASCAL/DELPHI:

procedure TicketMachine.StateChange();
var
NewInput : string;
begin
Write('Insert coin: ');
Readln(NewInput);
if (NewInput = 'C') then
begin
if (State = 'Counting') then
begin
State := 'Cancelled';
ReturnCoins();
end;
SetState('Idle')
end
else
if (NewInput = 'A') then

© UCLES 2016
414
Page 8 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 42

begin
if (Amount = 0) then
Writeln('No coins inserted')
else
begin
SetState('Accepted');
PrintTicket();
end;
SetState('Idle');
end
else
if (ValidCoin(NewInput)) then
begin
CoinInserted(NewInput);
SetState('Counting')
end
else
Writeln('Error - not a valid coin')
end;

VB:
Public Sub StateChange()
Dim NewInput As String
NewInput = Console.Readline()
If NewInput = “C” Then
If State = “Counting” Then
SetState(“Cancelled”)
ReturnCoins()
End If
SetState(“Idle”)
Elseif NewInput = “A” Then
If Amount = 0 Then
Console.Writeline(“No coins inserted”)
Else
SetState(“Accepted”)
PrintTicket()
Endif
SetState(“Idle”)
Elseif ValidCoin(NewInput) Then
CoinInserted(NewInput)
SetState(“Counting”)
Else
Console.Writeline(“Error – not a valid coin”)
EndIf
End Sub

© UCLES 2016
415
Page 9 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 42

(vii) 1 mark per bullet to max 4 [4]


• declaration of main method header
• Initialising ParkingMeter as instance of TicketMachine
• Looping while true/until false
o Calling stateChange method on ParkingMeter

e.g.

PYTHON:
def main():
ParkingMeter = TicketMachine()
while True:
ParkingMeter.stateChange()

PASCAL/DELPHI:
begin
ParkingMeter := TicketMachine.Create();
while True do
ParkingMeter.StateChange();
end.

VB:
Sub Main()
Dim ParkingMeter As New TicketMachine
ParkingMeter.Create()
While (True)
Call ParkingMeter.StateChange()
End While
End Sub

© UCLES 2016
416
Page 10 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 42

(c) (i) 1 mark per bullet to max 2: [2]

• The attributes can only be accessed in the class


• Properties are needed to get/set the data // It provides/uses encapsulation
• Increase security/integrity of attributes

(ii) 1 mark per bullet [2]

• The public methods can be called anywhere in the main program // Public methods
can be inherited by sub-classes

• The private methods can only be called within the class definition // cannot be called
outside the class definition // Private methods cannot be inherited by sub-classes

2 [6]
(i) Alpha testing (ii) Beta testing

Who In house testers / developers / (potential) (end) user(s)/client(s)


programmers

When Near the end of development // Before general release of software


program is nearly fully-usable // after // passed Alpha testing
integration and before beta

Purpose To find errors not found in earlier For constructive comments/


testing // ensure ready for beta feedback // to test in real-life
testing scenarios/situations/ environments
// ensure it is ready for release //
ensure it meets users’ needs

3 (a) (i) 1 mark per bullet to max 2: [2]


• 11011111
• AND

(ii) 1 mark per bullet to max 2: [2]


• 00100000
• OR

© UCLES 2016
417
Page 11 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 42

(b) 1 mark per line

START: LDR #0 // initialise index register to zero 1

LDX WORD // get first character of WORD 1

AND MASK1 // ensure it is in upper case using MASK1


1
OUT // output character to screen

INC IX // increment index register 1

LDM #1 // load 1 into ACC 1

STO COUNT // store in COUNT 1


// load next character from indexed address
LOOP: LDX WORD 1
WORD
OR MASK2 // make lower case using MASK2
1
OUT // output character to screen

LDD COUNT // increment COUNT

INC ACC // 1

STO COUNT //

CMP LENGTH // is COUNT = LENGTH? 1

JPN LOOP // if FALSE – jump to LOOP 1

END // end of program 1

COUNT: 0

MASK1: B11011111 // bit pattern for upper case


1
MASK2: B00100000 // bit pattern for lower case

LENGTH: 4

WORD: B01100110 //ASCII code in binary for 'f'

B01101000 //ASCII code in binary for 'r'

B01000101 //ASCII code in binary for 'E'

B01000100 //ASCII code in binary for 'D'

[max 12]

© UCLES 2016
418
Page 12 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 42

4 (a) (i) 1 mark per feature to max 3 [3]

e.g.

• auto-indent
• auto-complete / by example
• colour-coded keywords/ strings/ comments/ built-in functions/ user-defined function
names pop-up help
• can set indent width
• expand/collapse subroutines/code
• block highlighting

incorrect syntax highlighting/ underlining // dynamic syntax checker

(ii) Read and mark the answer as one paragraph. Mark a how and a when anywhere in the
answer.
1 mark for when, 1 mark for how.

e.g.

When:
• the error has been typed
• when the program is being run/compiled/interpreted

How:
• highlights/underlines
displays error message/pop-up

(iii) 1 mark for identifying the correct line, 1 mark for writing the corrected line

A - Line 5 B - Line 6 C - Line 5 [1]

for i in range(Max-1): FOR i := 1 TO (Max- For i = 0 To [1]


1) DO (Max – 1)

(b) (i) Python: compiled/interpreted [1]


VB.NET: compiled
Pascal:compiled/interpreted
Delphi: compiled/interpreted

© UCLES 2016
419
Page 13 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 42

(ii) 1 mark for naming error, 1 mark for line number and correction

A Logic error B Logic error C Logic error [1]

7 10 7 [1]
NoMoreSwaps = False NoMoreSwaps := NoMoreSwaps =
FALSE; False

(iii) 1 mark for naming, 1 for description [4]

• breakpoint
• a point where the program can be halted to see if the program works at this point

• stepping / step through


• executes one statement at a time and then pauses to see the effect of each
statement

• variable watch window


• observe how variables changed during execution

© UCLES 2016
420

Cambridge International Examinations


Cambridge International Advanced Subsidiary and Advanced Level
* 0 4 7 4 7 0 1 1 7 5 *

COMPUTER SCIENCE 9608/32


Paper 3 Advanced Theory May/June 2017
1 hour 30 minutes
Candidates answer on the Question Paper.
No Additional Materials are required.
No calculators allowed.

READ THESE INSTRUCTIONS FIRST

Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.

Answer all questions.


No marks will be awarded for using brand names of software packages or hardware.

At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.

The maximum number of marks is 75.

This document consists of 14 printed pages and 2 blank pages.

DC (ST/SW) 158024/4
© UCLES 2017 [Turn over
421
2

1 (a) Consider the following pseudocode user-defined data type:

TYPE MyContactDetail
DECLARE Name : STRING
DECLARE HouseNumber : INTEGER
ENDTYPE

(i) Write a pseudocode statement to declare a variable, NewFriend, of type


MyContactDetail.

.......................................................................................................................................[1]

(ii) Write a pseudocode statement that assigns 129 to the HouseNumber of NewFriend.

.......................................................................................................................................[1]

(b) The user-defined data type MyContactDetail needs to be modified by:

• adding a field called Area which can take three values, uptown, downtown or midtown
• amending the field HouseNumber so that house numbers can only be in the range 1 to
499.

Write the updated version of MyContactDetail.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

(c) A pointer is a variable that stores the address of a variable of a particular type.

Consider the pseudocode on page 3, which uses the following identifiers:

Identifier Data type Description


IPointer ^INTEGER pointer to an integer
Sum INTEGER an integer variable
MyInt1 INTEGER an integer variable
MyInt2 INTEGER an integer variable

© UCLES 2017 9608/32/M/J/17


422
3

Sum 91 // assigns the value 91 to the integer variable Sum


IPointer @Sum // assigns to IPointer the address of the
// integer variable Sum
MyInt1 IPointer^ // assigns to variable MyInt1 the value at an
// address pointed at by IPointer
IPointer^ MyInt2 // assigns the value in the variable MyInt2 to
// the memory location pointed at by IPointer

The four assignment statements are executed. The diagram shows the memory contents
after execution.

Memory
Variable Contents
Address

...

5848
5847
IPointer 5846 4402
5845

...

4403
Sum 4402 33
4401

...

3428
MyInt1 3427 91
MyInt2 3426 33
3425

...

Use the diagram to state the current values of the following expressions:

(i) IPointer .....................................................................................................................[1]

(ii) IPointer^ ...................................................................................................................[1]

(iii) @MyInt1 ......................................................................................................................[1]

(iv) IPointer^ = MyInt2 ...............................................................................................[1]

© UCLES 2017 9608/32/M/J/17 [Turn over


423
4

(d) Write pseudocode statements that will achieve the following:

(i) Place the address of MyInt2 in IPointer.

.......................................................................................................................................[1]

(ii) Assign the value 33 to the variable MyInt1.

.......................................................................................................................................[1]

(iii) Copy the value in MyInt2 into the memory location currently pointed at by IPointer.

.......................................................................................................................................[1]

© UCLES 2017 9608/32/M/J/17


424
5

2 The following incomplete table shows descriptions and terms relating to malware.

(a) Complete the table with appropriate description and terms.

Description Term
(i) Malicious code is installed on a personal computer
so that the user is misdirected to a fraudulent web ...................................... [1]
site without their knowledge.
(ii) An attempt to acquire sensitive information, often
for malicious reasons, by trying to deceive the user ...................................... [1]
through the contents of an email.
(iii)
.................................................................................

.................................................................................

.................................................................................
Worm
.................................................................................

.................................................................................

................................................................................. [2]

(b) State two vulnerabilities that the malware in part (a)(i) or part (a)(ii) can exploit.

Vulnerability 1 ...........................................................................................................................

...................................................................................................................................................

Vulnerability 2 ...........................................................................................................................

...................................................................................................................................................
[2]

© UCLES 2017 9608/32/M/J/17 [Turn over


425
6

(c) Digital certificates are used in internet communications. A Certificate Authority (CA) is
responsible for issuing a digital certificate.

The digital certificate contains a digital signature produced by the CA.

(i) Name three additional data items present in a digital certificate.

1 ........................................................................................................................................

2 ........................................................................................................................................

3 ........................................................................................................................................
[3]

(ii) Describe how the digital signature is produced by the CA.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

(iii) Give the reason for including a digital signature in the digital certificate.

...........................................................................................................................................

.......................................................................................................................................[1]

3 A logic circuit is shown:

S
Q

(a) Write the Boolean algebraic expression corresponding to this logic circuit:

S = ........................................................................................................................................[4]

© UCLES 2017 9608/32/M/J/17


426
7

(b) Complete the truth table for this logic circuit:

P Q R Working space S

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1
[2]

(c) (i) Complete the Karnaugh Map (K-map) for the truth table in part (b).
PQ
00 01 11 10
0
R
1
[1]

The K-map can be used to simplify the function in part (a).

(ii) Draw loop(s) around appropriate groups to produce an optimal sum-of-products. [1]

(iii) Write a simplified sum-of-products expression, using your answer to part (ii).

S = .................................................................................................................................[1]

(d) One Boolean identity is:


(A + B) . C = A . C + B . C

Simplify the expression for S in part (a) to the expression for S in part (c)(iii).

You should use the given identity and De Morgan’s Laws.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]
© UCLES 2017 9608/32/M/J/17 [Turn over
427
8

4 (a) Three file organisation methods and two file access methods are shown below.

Draw lines to link each file organisation method to its appropriate file access method(s).

File organisation method File access method

random sequential

serial direct

sequential

[4]

(b) An energy company supplies electricity to a large number of customers. Each customer has
a meter that records the amount of electricity used. Customers submit meter readings using
their online account.

The company’s computer system stores data about its customers.

This data includes:

• account number
• personal data (name, address, telephone number)
• meter readings
• username and encrypted password.

The computer system uses three files:

File Content Use


A Account number and meter readings Each time a customer submits their
for the current month. reading, a new record is added to the
file.
B Customer’s personal data. At the end of the month to create a
statement that shows the electricity
supplied and the total cost.
C Usernames and encrypted passwords. When customers log in to their
accounts to submit meter readings.

© UCLES 2017 9608/32/M/J/17


428
9

For each of the files A, B and C, state an appropriate file organisation method for the use
given in the table.

All three file organisation methods must be different.

Justify your choice.

(i) File A organisation .............................................................................................................

Justification .......................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

(ii) File B organisation ............................................................................................................

Justification .......................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

(iii) File C organisation ............................................................................................................

Justification .......................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

© UCLES 2017 9608/32/M/J/17 [Turn over


429
10

5 The TCP/IP protocol suite can be viewed as a stack with four layers.

(a) Complete the stack by inserting the names of the three missing layers.

Application layer

[3]

(b) BitTorrent is a protocol used at the Application layer for the exchange of data.

(i) State the network model used with this protocol.

.......................................................................................................................................[1]

(ii) State the use of BitTorrent.

.......................................................................................................................................[1]

(iii) Explain how the exchange of data is achieved using BitTorrent.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[4]

© UCLES 2017 9608/32/M/J/17


430
11

(c) State two additional protocols that are also used at the Application layer for the exchange of
data.

For each protocol, give an example of an appropriate exchange of data.

Protocol 1 .................................................................................................................................

Example ....................................................................................................................................

...................................................................................................................................................

Protocol 2 .................................................................................................................................

Example ....................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2017 9608/32/M/J/17 [Turn over


431
12

6 A large office building has many floors. On each floor there are security sensors and security
cameras. There is the same number of sensors on each floor. The building has a single security
room.

The images from the security cameras are output on monitors (one monitor for each floor) placed
in the security room.

The data from the sensors are read and processed by a computer system. Sensor readings and
warning messages can be displayed on the monitors.

(a) (i) State the name given to the type of system described.

.......................................................................................................................................[1]

(ii) Explain your answer to part (i).

...........................................................................................................................................

.......................................................................................................................................[1]

(iii) State two sensors that could be used in this system.

Sensor 1 ............................................................................................................................

Sensor 2 ............................................................................................................................
[2]

(b) A software routine:

• checks the readings from the sensors


• outputs readings and warning messages to the monitors
• loops continuously.

The routine uses the following pseudocode variables:

Identifier Data type Description


FloorCounter INTEGER Loop counter for number of floors
SensorCounter INTEGER Loop counter for number of sensors
NumberOfFloors INTEGER Stores the number of floors
NumberOfSensors INTEGER Stores the number of sensors
ForEver BOOLEAN Stores value that ensures continuous loop

© UCLES 2017 9608/32/M/J/17


432
13

(i) Complete the following pseudocode algorithm for the routine.

01 ForEver ...............................................................................................................
02 REPEAT
03 FOR FloorCounter 1 TO NumberOfFloors
04 FOR SensorCounter 1 TO ......................................................................
05 READ Sensor(SensorCounter)on Floor(FloorCounter)
06 IF Sensor value outside range
07 THEN
08 OUTPUT “Problem on Floor ”, FloorCounter
09 ENDIF
10 ENDFOR
11 ENDFOR
12 //
13 // Delay loop
14 // Delay loop
15 //
16 UNTIL .........................................................................................................................
[3]

(ii) A delay needs to be introduced before the loop is processed again.

Write a FOR loop, in pseudocode, to replace lines 13 and 14.

...........................................................................................................................................

.......................................................................................................................................[1]

(iii) Give a reason for this delay in the system.

...........................................................................................................................................

.......................................................................................................................................[1]

© UCLES 2017 9608/32/M/J/17 [Turn over


433
14

(c) An alternative method of reading and processing sensor data is to use interrupts. Each sensor
is connected so that it can send an interrupt signal to the processor if its value changes.

On receipt of an interrupt signal, the processor carries out a number of steps as shown in the
following diagram.

Interrupt 1. Disable interrupts

2. Save current task

3. Identify source of
interrupt

4. Jump to Interrupt
Service Routine

5. Restore task

Return to task 6. Enable interrupts

(i) State the purpose of step 3.

...........................................................................................................................................

.......................................................................................................................................[1]

(ii) Explain what happens at step 4.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

© UCLES 2017 9608/32/M/J/17


434
15

BLANK PAGE

© UCLES 2017 9608/32/M/J/17


435
16

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 International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.

Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.

© UCLES 2017 9608/32/M/J/17


436

Cambridge International Examinations


Cambridge International Advanced Subsidiary and Advanced Level

COMPUTER SCIENCE 9608/32


Paper 3 Written Paper May/June 2017
MARK SCHEME
Maximum Mark: 75

Published

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.

Cambridge will not enter into discussions about these mark schemes.

Cambridge is publishing the mark schemes for the May/June 2017 series for most Cambridge IGCSE®,
Cambridge International A and AS Level and Cambridge Pre-U components, and some Cambridge O Level
components.

® IGCSE is a registered trademark.

This document consists of 7 printed pages.

© UCLES 2017 [Turn over


9608/32 Cambridge International AS/A Level – Mark Scheme 437
May/June 2017
PUBLISHED

Question Answer Marks

1(a)(i) DECLARE NewFriend : MyContactDetail 1

1(a)(ii) NewFriend.HouseNumber ← 129 1

1(b) Declaration of Name, Area, HouseNumber 1 3


Inclusion of three correct values for Area 1
Inclusion of correct range for HouseNumber 1

For example:

TYPE MyContactDetail
DECLARE Name : STRING
DECLARE Area : (uptown, downtown, midtown) 1
DECLARE HouseNumber : 1..499 1&1
ENDTYPE

1(c)(i) 4402 1

1(c)(ii) 33 1

1(c)(iii) 3427 1

1(c)(iv) TRUE 1

1(d)(i) IPointer ← @MyInt2 1

1(d)(ii) MyInt1 ← 33 1

1(d)(iii) IPointer^ ← MyInt2 1

© UCLES 2017 Page 2 of 7


9608/32 Cambridge International AS/A Level – Mark Scheme 438
May/June 2017
PUBLISHED

Question Answer Marks

2(a)(i) Pharming 1

2(a)(ii) Phishing 1

2(a)(iii) A standalone/independent piece of malicious software 1 2


that can replicate/duplicate itself 1

2(b) No up-to-date anti-virus (or equivalent) software (used) / Regular virus scans not 2
performed
No firewall
Operating system not up-to-date/obsolete
Attachments/suspicious links in emails clicked on
Clicking on website with an out of date security certificate
max 2

2(c)(i) (Certificate) serial number 1 3


Certificate Authority (that issued certificate) 1
Valid date(s) // Date of expiry 1
Subject name (name of user/owner, computer, network device) 1
Subject public key 1
Version (Number) 1
Hashing algorithm (data or signature) 1
max 3

2(c)(ii) CA uses hashing algorithm .. 1 3


To generate a message digest from the particular certificate 1
Message digest is encrypted with CA’s private key 1

2(c)(iii) Need to know that the certificate is genuine (and has not been altered) 1
// Authenticate or verify it (came from the CA)

© UCLES 2017 Page 3 of 7


9608/32 Cambridge International AS/A Level – Mark Scheme 439
May/June 2017
PUBLISHED

Question Answer Marks

3(a) S = ( P + (Q+R) ) . R 4
P 1
(Q +R) 1
( P +( Q + R ) ) 1
.R (must be outside final brackets) 1

Or

P 1
(Q +R) 1
P +( Q + R ) 1
(«««..). R 1

3(b) P Q R Working space S 2

0 0 0 0

0 0 1 1

0 1 0 0

0 1 1 1

1 0 0 0

1 0 1 0

1 1 0 0

1 1 1 0
2 marks all correct, 1 mark seven correct, 0 marks six or fewer correct

3(c)(i) PQ 1

00 01 11 10
0 0 0 0 0
R
1 1 1 0 0

3(c)(ii) PQ 1

00 01 11 10
0 0 0 0 0
R
1 1 1 0 0

3(c)(iii) S= P .R 1

© UCLES 2017 Page 4 of 7


9608/32 Cambridge International AS/A Level – Mark Scheme 440
May/June 2017
PUBLISHED

Question Answer Marks

3(d) S = (P + ( Q + R ) ) . R 3
S = ( P + ( Q . R ) ) . R // P .R + ( Q + R ) . R 1
S = (P . R ) + ( Q . R . R ) 1
S= P . R + Q . 0 )
S= P . R + 0 ) 1
S= P . R

Question Answer Marks

4(a) File organisation File access 4


method method

random sequential

serial direct

sequential

1 mark for random correct


1 mark for serial correct
2 marks for sequential correct (1 per correct line)

4(b)(i) File A: 3
Serial 1
Meter readings are submitted over time // added to the end of file 1
Stored chronologically 1

4(b)(ii) File B: 3
Sequential 1
Any two points from:
Each customer has a unique account number 1
Sorted on Account number 1
High hit rate // Suitable for batch processing monthly statements 1

4(b)(iii) File C: 3
Random 1
Login without waiting // Random organisation allows fastest direct access to
required record 1
Low hit rate // Suitable for access to individual records 1

© UCLES 2017 Page 5 of 7


9608/32 Cambridge International AS/A Level – Mark Scheme 441
May/June 2017
PUBLISHED

Question Answer Marks

5(a) Option 1 Option 2 3

Application Layer Application Layer


Transport Transport (Layer) 1
Internet Network (Layer) 1
Network Interface (Data) Link (Layer) 1

5(b)(i) Peer-to-peer 1

5(b)(ii) File sharing 1

5(b)(iii) Any four points from the following: Max 4


• Torrent descriptor file is made available
• File to be shared is split into pieces
• BitTorrent client software made available to other peers / users / computers
Allowing them to work as seeds or leeches.
A peer can act as a ‘seed’ – used to upload pieces of a file
Peer downloading file can get pieces from different seeds simultaneously
• Once a peer has a piece of the file it can become a seed for the parts
downloaded
Leeches download much more than they upload
• Central server called a tracker keeps records of all the peers (‘swarm’) and
the parts of the file they have
Can pause and restart at any time.

5(c) Any two protocols from: Max 4


HTTP/HTTPS « 1
Used for transfer of web pages from server to client 1
FTP « 1
Used for interactive file transfer 1
SMTP « 1
Used for sending email messages 1
POP3 « 1
Used for incoming email messages 1

© UCLES 2017 Page 6 of 7


9608/32 Cambridge International AS/A Level – Mark Scheme 442
May/June 2017
PUBLISHED

Question Answer Marks

6(a)(i) Monitoring system 1

6(a)(ii) There is no element of ‘control’ in the system // the system does not alter 1
conditions in the building if sensors triggered

6(a)(iii) Any two sensors from: Max 2


Sound / acoustic
Pressure
Infra-red / motion /proximity
Temperature / Thermal
Light
Smoke
Tilt

6(b)(i) 01 ForEver ← FALSE //TRUE 1 3


02 REPEAT
03 FOR FloorCounter ← 1 TO NoOfFloors
04 FOR SensorCounter ← 1 TO NumberOfSensors 1
05 READ Sensor(SensorCounter)on Floor(FloorCounter)
06 IF Sensor value outside range
07 THEN
08 OUTPUT “Problem on Floor ”, FloorCounter
09 ENDIF
10 ENDFOR
11 ENDFOR
12 //
13 // Delay loop
14 // Delay loop
15 //
16 UNTIL ForEver/Forever = TRUE // NOT ForEver / ForEver =
FALSE 1

6(b)(ii) FOR Counter ← 1 TO 999999 (any “large” number) 1


ENDFOR

6(b)(iii) To allow time to elapse between readings 1

6(c)(i) To identify which sensor caused the interrupt 1

6(c)(ii) Display appropriate warning message 1 2


On the correct monitor 1

© UCLES 2017 Page 7 of 7


443

Cambridge International Examinations


Cambridge International Advanced Subsidiary and Advanced Level

COMPUTER SCIENCE 9608/42


Paper 4 Further Problem-solving and Programming Skills May/June 2017
PRE-RELEASE MATERIAL
* 5 9 4 9 3 3 2 2 1 3 *

No Additional Materials are required.


This material should be given to the relevant teachers and candidates as soon as it has been received
at the Centre.

READ THESE INSTRUCTIONS FIRST

Candidates should use this material in preparation for the examination. Candidates should attempt the
practical programming tasks using their chosen high-level, procedural programming language.

This document consists of 12 printed pages.

DC (ST/SW) 144372/1
© UCLES 2017 [Turn over
444
2

Teachers and candidates should read this material prior to the June 2017 examination for 9608 Paper 4.

Reminders

The syllabus states:

• there will be questions on the examination paper which do not relate to this pre-release material
• you must choose a high-level programming language from this list:

Visual Basic (console mode)


Python
Pascal / Delphi (console mode)

Note: A mark of zero will be awarded if a programming language other than those listed is used.

The practical skills for Paper 4 build on the practical skills covered in Paper 2. We therefore recommend
that candidates choose the same high-level programming language for this paper as they did for
Paper 2. This will give candidates the opportunity for extensive practice and allow them to acquire
sufficient expertise.

Questions on the examination paper may ask the candidate to write:

• structured English
• pseudocode
• program code

A program flowchart should be considered as an alternative to pseudocode for the documenting of an


algorithm design.

Candidates should be confident with:

• the presentation of an algorithm using either a program flowchart or pseudocode


• the production of a program flowchart from given pseudocode and vice versa.

Candidates will also benefit from using pre-release materials from previous examinations. These are
available on the teacher support site.

Declaration of variables

The syllabus document shows the syntax expected for a declaration statement in pseudocode.

DECLARE <identifier> : <data type>

If Python is the chosen language, each variable’s identifier (name) and its intended data type must be
documented using a comment statement.

Structured English – Variables

An algorithm in pseudocode uses variables, which should be declared. An algorithm in structured


English does not always use variables. In this case, the candidate needs to use the information given
in the question to complete an identifier table. The table needs to contain an identifier, data type and
description for each variable.

© UCLES 2017 9608/42/PRE/M/J/17


445
3

TASK 1

Students at a college are given several tests during their course. A teacher wants to write
object-oriented software to process data about the tests.
For each test, the following are to be stored:

• one or more questions, up to a maximum of 10 questions


• the maximum number of marks for the test
• the level (A, S, G)

For each question, the following are to be stored:

• the question text


• the answer
• the maximum number of marks
Key focus: Object-oriented programming
• the topic

TASK 1.1

The relationship between Test and Question is shown in the following containment (aggregation)
class diagram.

Test Question
– TestID : String – QuestionID : String
– Questions [1 : 10] : Question – QuestionText : String
– NumberOfQuestions : Integer – Answer : String
1 1..*
– MaxMarks : Integer – Marks : Integer
– Level : Char – Topic : String
– DateSet : Date
+ SetQuestion()
+ DesignTest() + GetQuestion() : String
+ PrintTest() + GetMarks() : Integer
+ PrintAnswers() + GetTopic() : String
+ GetAnswer() : String

Explain what containment means in the context of OOP.

Investigate what other information this diagram conveys.

TASK 1.2

Write object-oriented program code to implement the classes.

Remember to use validation and error trapping where appropriate.

© UCLES 2017 9608/42/PRE/M/J/17 [Turn over


446
4

TASK 2

The table shows part of the instruction set for a processor which has one general purpose register, the
Accumulator (ACC), and an Index Register (IX).

Note: these instructions are referred to in the syllabus sections 1.4.3 and 3.6.2.

Instruction
Op Explanation
Operand
code
LDM #n Immediate addressing. Load the number n to ACC.
Direct addressing. Load the contents of the location at the given address to
LDD <address>
ACC.
Indirect addressing. The address to be used is at the given address. Load the
LDI <address>
contents of this second address to ACC.
Indexed addressing. Form the address from <address> + the contents of the
LDX <address>
index register. Copy the contents of this calculated address to ACC.
LDR #n Immediate addressing. Load the number n into IX.
STO <address> Store the contents of ACC at the given address.
ADD <address> Add the contents of the given address to the ACC.
INC <register> Add 1 to the contents of the register (ACC or IX).
DEC <register> Subtract 1 from the contents of the register (ACC or IX).
JMP <address> Jump to the given address.
CMP <address> Compare the contents of ACC with the contents of <address>.
CMP #n Compare the contents of ACC with number n.
JPE <address> Following a compare instruction, jump to <address> if the compare was TRUE.
JPN <address> Following a compare instruction, jump to <address> if the compare was FALSE.
AND #n Bitwise AND operation of the contents of ACC with the operand.
AND <address> Bitwise AND operation of the contents of ACC with the contents of <address>.
XOR #n Bitwise XOR operation of the contents of ACC with the operand.
XOR <address> Bitwise XOR operation of the contents of ACC with the contents of <address>.
OR #n Bitwise OR operation of the contents of ACC with the operand.
OR <address> Bitwise OR operation of the contents of ACC with the contents of <address>.
IN Key in a character and store its ASCII value in ACC.
OUT Output to the screen the character whose ASCII value is stored in ACC.
END Return control to the operating system.

© UCLES 2017 9608/42/PRE/M/J/17


447
5

Notes:

# denotes immediate addressing


B denotes a binary number, for example, B01001010
& denotes a hexadecimal number, for example, &4A

Tasks 2.1 to 2.7 all use one of the following two formats for symbolic addressing.

Format Example
<label>: <op code> <operand> START: LDM #0
<label>: <data> NUM1: B01001010

Key focus: Low-level programming

Tasks 2.1 to 2.5 show high-level language constructs written in pseudocode. Each task consists of
writing the assembly language equivalent of the given high-level language construct.

Write assembly language program code using the given instruction set.

© UCLES 2017 9608/42/PRE/M/J/17 [Turn over


448
6

TASK 2.1

X A + B
END

Instruction
Label Op Comment
Operand
code

START: // load the content of A into ACC

// add the content of B to content of ACC

// store content of ACC at address X

END // end of program

X:

A: 5

B: 3

© UCLES 2017 9608/42/PRE/M/J/17


449
7

TASK 2.2

IF X = A
THEN
OUTPUT CHR(X) // statements for THEN part
ELSE
A A + 1 // statements for ELSE part
ENDIF
END

Instruction
Label Op Comment
Operand
code

START: // load the content of X into ACC

// compare the content of ACC with content of A

// if not equal (FALSE), jump to ELSE

THEN: // instruction for the THEN part goes here

JMP ENDIF // jump over the ELSE part

ELSE: // instructions for ELSE part start here

ENDIF: END // end of program

A: 65

X: 67

Note: the built-in function CHR(X) returns the character that is represented by the ASCII code held
in X.

© UCLES 2017 9608/42/PRE/M/J/17 [Turn over


450
8

TASK 2.3

REPEAT
OUTPUT CHR(X)
X X - 1
UNTIL X = A
END

Instruction
Label Op Comment
Operand
code

LOOP: // instructions to be repeated start here

// is content of ACC = content of A ?

// if not equal (FALSE), jump to LOOP

END // end of program

X: 90

A: 65

© UCLES 2017 9608/42/PRE/M/J/17


451
9

TASK 2.4

FOR COUNT 1 TO 4
OUTPUT CHARS[COUNT]
ENDFOR
END

Instruction
Label Op Comment
Operand
code

// set ACC to 1

// store contents of ACC in COUNT

// set IX to 0

LOOP: // COUNT = 4 + 1 ? starts here

// if equal (TRUE), jump to ENDFOR

// instructions to be repeated start here

// increment IX

// increment COUNT starts here

// jump to LOOP

ENDFOR: END // end of program

COUNT:

CHARS: 72 // 'H'

69 // 'E'

76 // 'L'

80 // 'P'

© UCLES 2017 9608/42/PRE/M/J/17 [Turn over


452
10

TASK 2.5

WHILE X <> B
OUTPUT CHARS[B]
B B + 1
ENDWHILE
END

Instruction
Label Op Comment
Operand
code
LOOP: // load contents of X into ACC
// is contents of ACC = contents of B ?
// if equal (TRUE), jump to ENDWHILE
// instructions to be repeated start here
// set IX to B starts here
// set ACC to 1
// store content of ACC in FORCOUNT
// FORCOUNT = B + 1 ? starts here
// decrement ACC to FORCOUNT - 1
// FORCOUNT – 1 = B ?
// if equal (TRUE), jump to ENDFOR
// increment IX

// output CHARS[B] starts here

// increment B starts here

// jump back to start of while loop


END // end of program
FORCOUNT: // control variable for inner loop
X: 4
B: 0
CHARS: 72 // 'H'
69 // 'E'
76 // 'L'
80 // 'P'

© UCLES 2017 9608/42/PRE/M/J/17


453
11

TASK 2.6

Output a string using indirect addressing.

Instruction
Address Op Comment
Operand
code
// use indirect addressing to load contents of
LOOP:
address found at address 100

// output character with ASCII code held in ACC

// load content of address 100

// increment ACC

// store content of ACC at address 100

// is content of ACC = 107 ?

// if not equal (FALSE), jump to LOOP

END // end of program

100 102

101

102 77 // 'M'

103 65 // 'A'

104 84 // 'T'

105 72 // 'H'

106 83 // 'S'

107

© UCLES 2017 9608/42/PRE/M/J/17 [Turn over


454
12

TASK 2.7

Programmers use bitwise operations (AND, OR, XOR) to set or examine specific bits.

Example:

Instruction
Label Op Comment
Operand
code

START: LDD X // load content of X into ACC

// bitwise AND operation on content of ACC and


AND MASK
content of MASK

STO Y // store content of ACC in Y

END // end of program

X: B10101111

Y: // what does the value of Y tell you about X ?

MASK: B00000001

Write simple programs using the different bitwise operations (AND, OR, XOR) and different MASK content.

Identify the operation and MASK bit pattern to:


• set a bit to 1, leaving all other bits unchanged
• set a bit to 0, leaving all other bits unchanged
• test whether a specific bit is 1
• test whether a specific bit is 0.

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 International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.

Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.

© UCLES 2017 9608/42/PRE/M/J/17


455

Cambridge International Examinations


Cambridge International Advanced Subsidiary and Advanced Level
* 6 3 6 6 2 6 7 4 2 0 *

COMPUTER SCIENCE 9608/42


Paper 4 Further Problem-solving and Programming Skills May/June 2017
2 hours
Candidates answer on the Question Paper.
No Additional Materials are required.
No calculators allowed.

READ THESE INSTRUCTIONS FIRST

Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.

Answer all questions.


No marks will be awarded for using brand names of software packages or hardware.

At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.

The maximum number of marks is 75.

This document consists of 17 printed pages and 3 blank pages.

DC (CW/SW) 129963/3
© UCLES 2017 [Turn over
456
2

1 The following table shows part of the instruction set for a processor which has one general purpose
register, the Accumulator (ACC), and an Index Register (IX).

Instruction
Explanation
Op code Operand
LDM #n Immediate addressing. Load the number n to ACC.
LDD <address> Direct addressing. Load the contents of the location at the given address
to ACC.
LDI <address> Indirect addressing. The address to be used is at the given address.
Load the contents of this second address to ACC.
LDX <address> Indexed addressing. Form the address from <address> + the contents of
the index register. Copy the contents of this calculated address to ACC.
STO <address> Store the contents of ACC at the given address.
INC <register> Add 1 to the contents of the register (ACC or IX).
CMP <address> Compare the contents of ACC with the contents of <address>.
JMP <address> Jump to the given address.
JPE <address> Following a compare instruction, jump to <address> if the compare was
True.
JPN <address> Following a compare instruction, jump to <address> if the compare was
False.
AND <address> Bitwise AND operation of the contents of ACC with the contents of
<address>.
XOR <address> Bitwise XOR operation of the contents of ACC with the contents of
<address>.
OR <address> Bitwise OR operation of the contents of ACC with the contents of
<address>.
IN Key in a character and store its ASCII value in ACC.
OUT Output to the screen the character whose ASCII value is stored in ACC.
END Return control to the operating system.

(a) A programmer writes a program that:

• reads two characters input from the keyboard (you may assume they will be capital
letters in ascending alphabetical sequence)
• outputs the alphabetical sequence of characters from the first to the second character.
For example, if the characters ‘B’ and ‘F’ are input, the output is:

BCDEF

© UCLES 2017 9608/42/M/J/17


457
3

The programmer has started to write the program in the following table. The Comment column
contains descriptions for the missing program instructions, labels and data.

Complete the following program. Use op codes from the given instruction set.

Op
Label Operand Comment
code
START: // INPUT character
// store in CHAR1
// INPUT character
// store in CHAR2
// initialise ACC to ASCII value of CHAR1
// output contents of ACC
// compare ACC with CHAR2
// if equal jump to end of FOR loop
// increment ACC
// jump to LOOP
ENDFOR: END
CHAR1:
CHAR2:
[9]

(b) The programmer now starts to write a program that:

• converts a positive integer, stored at address NUMBER1, into its negative equivalent in
two’s complement form
• stores the result at address NUMBER2

Complete the following program. Use op codes from the given instruction set.
Show the value stored in NUMBER2.

Op
Label Operand Comment
code
START:
MASK // convert to one's complement
// convert to two's complement

END
MASK: // show value of mask in binary here
NUMBER1: B00000101 // positive integer
NUMBER2: // negative equivalent
[6]

© UCLES 2017 9608/42/M/J/17 [Turn over


458
4

2 An ordered binary tree Abstract Data Type (ADT) has these associated operations:

• create tree
• add new item to tree
• traverse tree

The binary tree ADT is to be implemented as a linked list of nodes.

Each node consists of data, a left pointer and a right pointer.

(a) A null pointer is shown as O.

Explain the meaning of the term null pointer.

...................................................................................................................................................

...............................................................................................................................................[1]

(b) The following diagram shows an ordered binary tree after the following data have been
added:

Dublin, London, Berlin, Paris, Madrid, Copenhagen

RootPointer

Dublin

Ø Berlin Ø London

Ø Copenhagen Ø Paris Ø

Ø Madrid Ø

Another data item to be added is Athens.

Make the required changes to the diagram when this data item is added. [2]

© UCLES 2017 9608/42/M/J/17


459
5

(c) A tree without any nodes Unused nodes are linked together into a free list
is represented as: as shown:

RootPointer FreePointer
Ø

Ø Ø

The following diagram shows an array of records that stores the tree shown in part (b).

(i) Add the relevant pointer values to complete the diagram.

RootPointer LeftPointer Tree data RightPointer


0 [0] Dublin

[1] London

[2] Berlin

[3] Paris

[4] Madrid

FreePointer [5] Copenhagen

[6] Athens

[7]

[8]

[9]

[5]

© UCLES 2017 9608/42/M/J/17 [Turn over


460
6

(ii) Give an appropriate numerical value to represent the null pointer for this design. Justify
your answer.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(d) A program is to be written to implement the tree ADT. The variables and procedures to be
used are listed below:

Identifier Data type Description


Data structure to store node data and associated
Node RECORD
pointers.
LeftPointer INTEGER Stores index of start of left subtree.
RightPointer INTEGER Stores index of start of right subtree.
Data STRING Data item stored in node.
Tree ARRAY Array to store nodes.
NewDataItem STRING Stores data to be added.
FreePointer INTEGER Stores index of start of free list.
RootPointer INTEGER Stores index of root node.
NewNodePointer INTEGER Stores index of node to be added.
Procedure initialises the root pointer and free pointer
CreateTree()
and links all nodes together into the free list.
Procedure to add a new data item in the correct
AddToTree()
position in the binary tree.
Procedure that finds the node where a new node is
to be added.
Procedure takes the parameter NewDataItem and
returns two parameters:
FindInsertionPoint()
• Index, whose value is the index of the node
where the new node is to be added
• Direction, whose value is the direction of the
pointer (“Left” or “Right”).

© UCLES 2017 9608/42/M/J/17


461
7

(i) Complete the pseudocode to create an empty tree.

TYPE Node

.....................................................................................................................................

.....................................................................................................................................

.....................................................................................................................................

ENDTYPE

DECLARE Tree : ARRAY[0 : 9] ................................................................................

DECLARE FreePointer : INTEGER

DECLARE RootPointer : INTEGER

PROCEDURE CreateTree()

DECLARE Index : INTEGER

.....................................................................................................................................

.....................................................................................................................................

FOR Index ← 0 TO 9 // link nodes

..............................................................................................................................

..............................................................................................................................

ENDFOR

.....................................................................................................................................

ENDPROCEDURE [7]

© UCLES 2017 9608/42/M/J/17 [Turn over


462
8

(ii) Complete the pseudocode to add a data item to the tree.

PROCEDURE AddToTree(BYVALUE NewDataItem : STRING)

// if no free node report an error

IF FreePointer ...............................................................................................................

THEN

OUTPUT("No free space left")

ELSE // add new data item to first node in the free list

NewNodePointer ← FreePointer

.................................................................................................................................

// adjust free pointer

FreePointer ← .................................................................................................

// clear left pointer

Tree[NewNodePointer].LeftPointer ← ......................................................

// is tree currently empty ?

IF ...........................................................................................................................

THEN // make new node the root node

....................................................................................................................

ELSE // find position where new node is to be added

Index ← RootPointer

CALL FindInsertionPoint(NewDataItem, Index, Direction)

IF Direction = "Left"

THEN // add new node on left

.......................................................................................................

ELSE // add new node on right

.......................................................................................................

ENDIF

ENDIF

ENDIF

ENDPROCEDURE [8]

© UCLES 2017 9608/42/M/J/17


463
9

(e) The traverse tree operation outputs the data items in alphabetical order. This can be written
as a recursive solution.

Complete the pseudocode for the recursive procedure TraverseTree.

PROCEDURE TraverseTree(BYVALUE Pointer : INTEGER)

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

ENDPROCEDURE [5]

© UCLES 2017 9608/42/M/J/17 [Turn over


464
10

3 A programmer is writing a treasure island game to be played on the computer. The island is
a rectangular grid, 30 squares by 10 squares. Each square of the island is represented by an
element in a 2D array. The top left square of the island is represented by the array element [0, 0].
There are 30 squares across and 10 squares down.

The computer will:

• generate three random locations where treasure will be buried


• prompt the player for the location of one square where the player chooses to dig
• display the contents of the array by outputting for each square:

– '.' for only sand in this square


– 'T' for treasure still hidden in sand
– 'X' for a hole dug where treasure was found
– 'O' for a hole dug where no treasure was found.

Here is an example display after the player has chosen to dig at location [9, 3]:

..............................
..............................
..............................
..............................
..............................
........T.....................
..............................
..............................
.........T....................
...X..........................

The game is to be implemented using object-oriented programming.

The programmer has designed the class IslandClass. The identifier table for this class is:

Identifier Data type Description


2D array to represent the
Grid ARRAY[0 : 9, 0 : 29] OF CHAR
squares of the island
instantiates an object of class
Constructor() IslandClass and initialises
all squares to sand
generates a pair of random
numbers used as the grid
HideTreasure()
location of treasure and
marks the square with 'T'
takes as parameters a valid
grid location and marks the
DigHole(Row, Column)
square with 'X' or 'O' as
appropriate
takes as parameter a valid
grid location and returns the
GetSquare(Row, Column) CHAR grid value for that square
from the IslandClass
object

© UCLES 2017 9608/42/M/J/17


465
11

(a) The programmer designed the pseudocode for the main program as follows:

DECLARE Island : IslandClass.Constructor() // instantiate object

CALL DisplayGrid() // output island squares

FOR Treasure ← 1 TO 3 // hide 3 treasures

CALL Island.HideTreasure()

ENDFOR

CALL StartDig() // user to input location of dig

CALL DisplayGrid() // output island squares

Write program code to implement this pseudocode.

Programming language used ...................................................................................................

Program code ...........................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

© UCLES 2017 9608/42/M/J/17 [Turn over


466
12

(b) Write program code to declare the IslandClass and write the constructor method.

The value to represent sand should be declared as a constant.

Programming language used ...................................................................................................

Program code ...........................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]

© UCLES 2017 9608/42/M/J/17


467
13

(c) The procedure DisplayGrid shows the current grid data. DisplayGrid makes use of the
getter method GetSquare of the Island class.

An example output is:

..............................
..............................
..............................
..............................
..............................
........T.....................
..............................
..............................
.........T....................
...X..........................

(i) Write program code for the GetSquare(Row, Column) getter method.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(ii) Write program code for the DisplayGrid procedure.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[4]

© UCLES 2017 9608/42/M/J/17 [Turn over


468
14

(d) Write program code for the HideTreasure method. Your method should check that the
random location generated does not already contain treasure.

The value to represent treasure should be declared as a constant.

Programming language used ...................................................................................................

Program code ...........................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]

© UCLES 2017 9608/42/M/J/17


469
15

(e) (i) The DigHole method takes two integers as parameters. These parameters form a valid
grid location. The location is marked with 'X' or 'O' as appropriate.

Write program code for the DigHole method. The values to represent treasure, found
treasure and hole should be declared as constants.

Programming language used ............................................................................................

Program code ....................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

© UCLES 2017 9608/42/M/J/17 [Turn over


470
16

(ii) The StartDig procedure:

• prompts the player for a location to dig


• validates the user input
• calls the DigHole method from part (e)(i).

Write program code for the StartDig procedure. Ensure that the user input is fully
validated.

Programming language used ............................................................................................

Program code ....................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[5]
© UCLES 2017 9608/42/M/J/17
471
17

(f) (i) The squares in the IslandClass grid could have been declared as objects of a
Square class.

State the term used to describe the relationship between IslandClass and Square.

...........................................................................................................................................

.......................................................................................................................................[1]

(ii) Draw the appropriate diagram to represent this relationship. Do not list the attributes and
methods of the classes.

[2]

© UCLES 2017 9608/42/M/J/17


472
18

BLANK PAGE

© UCLES 2017 9608/42/M/J/17


473
19

BLANK PAGE

© UCLES 2017 9608/42/M/J/17


474
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 International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.

Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.

© UCLES 2017 9608/42/M/J/17


475

Cambridge International Examinations


Cambridge International Advanced Subsidiary and Advanced Level

COMPUTER SCIENCE 9608/42


Paper 4 Written Paper May/June 2017
MARK SCHEME
Maximum Mark: 75

Published

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.

Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.

Cambridge will not enter into discussions about these mark schemes.

Cambridge is publishing the mark schemes for the May/June 2017 series for most Cambridge IGCSE®,
Cambridge International A and AS Level and Cambridge Pre-U components, and some Cambridge O Level
components.

® IGCSE is a registered trademark.

This document consists of 19 printed pages.

© UCLES 2017 [Turn over


9608/42 Cambridge International AS/A Level – Mark Scheme 476
May/June 2017
PUBLISHED
Question Answer Marks
1(a) Op 9
Label Operand Comment
code
START: IN // INPUT character
1
STO CHAR1 // store in CHAR1
IN // INPUT character
1
STO CHAR2 // store in CHAR2
LDD CHAR1 // initialise ACC to ASCII value of CHAR1 1
LOOP: OUT //output contents of ACC 1+1
CMP CHAR2 // compare ACC with CHAR2 1
JPE ENDFOR // if equal jump to end of FOR loop 1
INC ACC // increment ACC 1
JMP LOOP // jump to LOOP 1
ENDFOR: END
CHAR1:
CHAR2:

1(b) Op 6
Label Operand Comment
code
START: LDD NUMBER1 1
XOR MASK // convert to one's complement 1
INC ACC // convert to two's complement 1
STO NUMBER2 1
END
MASK: B11111111 // show value of mask in binary here 1
NUMBER1: B00000101 // positive integer
NUMBER2: B11111011 // show value of negative equivalent 1

© UCLES 2017 Page 2 of 19


9608/42 Cambridge International AS/A Level – Mark Scheme 477
May/June 2017
PUBLISHED
Question Answer Marks
2(a) • A pointer that doesn’t point to another node/other data/address // indicates the end of the branch 1
2(b) one mark per bullet 2
• node with ‘Athens’ linked to left pointer of Berlin (ignore null pointer)
• null pointers in left and right pointers of Athens
2(c)(i) 5
RootPointer LeftPointer Tree Data RightPointer
0 [0] 2 Dublin 1
[1] -1/∅ London 3
[2] 6 Berlin 5
[3] 4 Paris -1/∅
[4] -1/∅ Madrid -1/∅
FreePointer [5] -1/∅ Copenhagen -1/∅
7 [6] -1/∅ Athens -1/∅
1 mark [7] 8 -1/∅
[8] 9 -1/∅
[9] -1/∅ -1/∅

2(c)(ii) • –1 2
• It is not the number for any node.

© UCLES 2017 Page 3 of 19


9608/42 Cambridge International AS/A Level – Mark Scheme 478
May/June 2017
PUBLISHED
Question Answer Marks
2(d)(i) TYPE Node 7
LeftPointer : INTEGER
RightPointer : INTEGER 1

Data : STRING
ENDTYPE
DECLARE Tree : ARRAY[0 : 9] OF Node 1

DECLARE FreePointer : INTEGER


DECLARE RootPointer : INTEGER

PROCEDURE CreateTree()
DECLARE Index : INTEGER

RootPointer ← -1 1

FreePointer ← 0 1

FOR Index ← 0 TO 9 // link nodes

Tree[Index].LeftPointer ← Index + 1 1

Tree[Index].RightPointer ← -1 1

ENDFOR

Tree[9].LeftPointer ← -1 1

ENDPROCEDURE

© UCLES 2017 Page 4 of 19


9608/42 Cambridge International AS/A Level – Mark Scheme 479
May/June 2017
PUBLISHED
Question Answer Marks
2(d)(ii) PROCEDURE AddToTree(ByVal NewDataItem : STRING) 8
// if no free node report an error

IF FreePointer = -1 1

THEN
ERROR("No free space left")
ELSE // add new data item to first node in the free list
NewNodePointer ← FreePointer

Tree[NewNodePointer].Data ← NewDataItem 1

// adjust free pointer


FreePointer ← Tree[FreePointer].LeftPointer 1

// clear left pointer

Tree[NewNodePointer].LeftPointer ← -1 1

// is tree currently empty ?


IF RootPointer = -1 1

THEN // make new node the root node


RootPointer ← NewNodePointer 1

ELSE // find position where new node is to be added


Index ← RootPointer
CALL FindInsertionPoint(NewDataItem, Index, Direction)

© UCLES 2017 Page 5 of 19


9608/42 Cambridge International AS/A Level – Mark Scheme 480
May/June 2017
PUBLISHED
Question Answer Marks
IF Direction = "Left"
THEN // add new node on left
Tree[Index].LeftPointer ← NewNodePointer 1

ELSE // add new node on right


Tree[Index].RightPointer ← NewNodePointer 1

ENDIF
ENDIF
ENDIF
ENDPROCEDURE

2(e) 1 mark per bullet 5


• test for base case (null/-1)
• recursive call for left pointer
• output data
• recursive call for right pointer
• order, visit left, output, visit right
IF Pointer <> NULL 1

THEN

TraverseTree(Tree[Pointer].LeftPointer) 1

OUTPUT Tree[Pointer].Data 1+1

TraverseTree(Tree[Pointer].RightPointer) 1

ENDIF

ENDPROCEDURE

© UCLES 2017 Page 6 of 19


9608/42 Cambridge International AS/A Level – Mark Scheme 481
May/June 2017
PUBLISHED
Question Answer Marks
3(a) 1 mark per bullet 3
• Instantiation of island object and calling DisplayGrid
• Loop 3 times and Island.HideTreasure
• Call procedures StartDig and DisplayGrid

Example Python

Island = IslandClass() 1
DisplayGrid()
for Treasure in range(3):
Island.HideTreasure() 1
StartDig()

DisplayGrid() 1

Example Pascal

var Island : IslandClass;


var Treasure : integer;
begin
Island := IslandClass.Create(); 1
DisplayGrid;
for Treasure := 1 to 3 do
Island.HideTreasure(); 1
StartDig;

DisplayGrid; 1
end;

© UCLES 2017 Page 7 of 19


9608/42 Cambridge International AS/A Level – Mark Scheme 482
May/June 2017
PUBLISHED
Question Answer Marks
Example VB.NET
Dim Island As New IslandClass() 1
DisplayGrid()
For Treasure = 1 To 3

Island.HideTreasure() 1
Next
StartDig()
DisplayGrid() 1

© UCLES 2017 Page 8 of 19


9608/42 Cambridge International AS/A Level – Mark Scheme 483
May/June 2017
PUBLISHED
Question Answer Marks
3(b) 1 mark per bullet to max 5 5
• Class heading and ending (in appropriate place)
• Constructor heading and ending (in appropriate place)
• Declaring grid with correct dimensions (as private)
• Declaring Sand as a constant
• Nested loops covering dimensions (0 – 29 and 0 – 9)
• Assigning Sand // ’.’ to each array element

Example Python
class IslandClass: 1
def __init__(self): 1
Sand = '.' 1
self.__Grid = [[Sand for j in range(30)] 1+1
for i in range(10)] 1

Example Pascal
type
IslandClass = class 1
private
Grid : array[0..9, 0..29] of char; 1
public
constructor Create();
procedure HideTreasure();
procedure DigHole(x, y : integer);
function GetSquare(x, y : integer) : char;
end;
constructor IslandClass.Create(); 1
const Sand = '.'; 1
var i, j : integer;
begin
for i := 0 to 9 do
for j := 0 to 29 do 1
Grid[i, j] := Sand; 1
end;

© UCLES 2017 Page 9 of 19


9608/42 Cambridge International AS/A Level – Mark Scheme 484
May/June 2017
PUBLISHED
Question Answer Marks
Example VB.NET
Class IslandClass 1
Private Grid (9, 29) As Char 1
Public Sub New() 1
Const Sand = "." 1
For i = 0 To 9
For j = 0 To 29 1
Grid(i, j) = Sand 1
Next
Next
End Sub
End Class

3(c)(i) 1 mark per bullet 2


• Method (getter or property) heading, takes two parameters returns char, and ending
• Method returns Grid value

Example Python
def GetSquare(self, Row, Column) : 1
return self.__Grid[Row][Column] 1

Example Pascal
function IslandClass.GetSquare( Row, Column : integer) As Char; 1
begin
Result := Grid[Row, Column];
end; 1

Example VB.NET
Public Function GetSquare(Row As Integer, Column As Integer) As Char 1
Return Grid(Row, Column) 1
end Function

© UCLES 2017 Page 10 of 19


9608/42 Cambridge International AS/A Level – Mark Scheme 485
May/June 2017
PUBLISHED
Question Answer Marks
3(c)(ii) 1 mark per bullet 4
• DisplayGrid header and ending, with two loops with correct limits
• Calling Island.GetSquare with correct parameters inside iteration
• Output an entire row in one line
• Output a new line at the end of a row

Example Python
def DisplayGrid() :
for i in range (10) :
for j in range (30) : 1
print(island.GetSquare(i, j), end='') 1+1
print() 1

Example Pascal
procedure DisplayGrid():
var i, j : integer;
begin
for i := 0 to 9 do
begin
for j := 0 to 29 do 1
write(island.GetSquare(i, j))); 1+1
writeLn; 1
end;
end;

Example VB.NET
Sub DisplayGrid()
For i = 0 to 9
For j = 0 to 29 1
Console.Write(island.GetSquare(i, j)) 1+1
Next
Console.WriteLine() 1
Next
End Sub

© UCLES 2017 Page 11 of 19


9608/42 Cambridge International AS/A Level – Mark Scheme 486
May/June 2017
PUBLISHED
Question Answer Marks
3(d) 1 mark per bullet to max 5 Max 5
• Method header and Declaring Treasure as a constant
• Generating a random number for column
• Generating a random number for row
• Check whether treasure already at generated location
• Repeatedly generate new coordinates in a loop
• Assign Treasure to location

Example Python
def HideTreasure(self): 1
Treasure = 'T'
x = randint(0,9) 1
y = randint(0,29) 1
while self.__Grid[y][x] == Treasure: 1+1
x = randint(0,9)
y = randint(0,29)
self.__Grid[y][x] = Treasure 1

Example Pascal
procedure IslandClass.HideTreasure();
const Treasure = 'T'; 1
var x, y : integer;
begin
repeat
x := Random(10); 1
y := random(30); 1
until Grid[x, y] <> Treasure; 1+1
Grid[x, y] := Treasure; 1
end;

© UCLES 2017 Page 12 of 19


9608/42 Cambridge International AS/A Level – Mark Scheme 487
May/June 2017
PUBLISHED
Question Answer Marks
Example VB.NET
Public Sub HideTreasure()
Const Treasure = "T" 1
Dim RandomNumber As New Random
Dim x, y As Integer
Do
x = RandomNumber.Next(0, 10) 1
y = RandomNumber.Next(0, 30) 1
Loop Until Grid(x, y) <> Treasure 1+1
Grid(x, y) = Treasure 1
End Sub

© UCLES 2017 Page 13 of 19


9608/42 Cambridge International AS/A Level – Mark Scheme 488
May/June 2017
PUBLISHED
Question Answer Marks
3(e)(i) 1 mark per bullet 3
• Method heading, with two parameters & Declaring constants for Treasure, Hole and FoundTreasure
• Check if treasure at parameter locations
• Set to FoundTreasure (X) and Set to Hole (O)

Example Python
def DigHole(self, x, y) :
Treasure = 'T'
Hole = 'O' 1
Foundtreasure = 'X'
if self.__Grid[x][y] == Treasure: 1
self.__Grid[x][y] = Foundtreasure
else : 1
self.__Grid[x][y] = Hole
return

Example Pascal
procedure IslandClass.DigHole(x, y : integer);
const Treasure = 'T';
const Hole = 'O';
const Foundtreasure = 'X'; 1
begin
if Grid[x, y] = Treasure 1
then
Grid[x, y] := Foundtreasure
else
Grid[x, y] := Hole; 1
end;

© UCLES 2017 Page 14 of 19


9608/42 Cambridge International AS/A Level – Mark Scheme 489
May/June 2017
PUBLISHED
Question Answer Marks
Example VB.NET
Public Sub DigHole(x As Integer, y As Integer)
Const Treasure = "T"
Const Hole = "O"
Const Foundtreasure = "X" 1
If Grid(x, y) = Treasure Then 1
Grid(x, y) = Foundtreasure
Else
Grid(x, y) = Hole 1
End If
End Sub

© UCLES 2017 Page 15 of 19


9608/42 Cambridge International AS/A Level – Mark Scheme 490
May/June 2017
PUBLISHED
Question Answer Marks
3(e)(ii) 1 mark per bullet to max 5 Max 5
• Prompt to user for position down and across, read positions input as an IntegerValidation for position row – between
0 and 9
• Validation for position column- between 0 and 29
• Exception handling/pass for validation
• Ask for repeated input until valid (for both row and column)
• Call Island.DigHole method with the coordinates

Example Python
def StartDig() :
Valid = False
while not Valid : # validate down position 1
try:
x = int(input("position down <0 to 9> ? ")) 1
if x >= 0 and x <= 9 : 1
Valid = True
except:
Valid = False
Valid = False
while not Valid : # validate across position
try :
y = int(input("position across <0 to 29> ? ")) 1
if y >= 0 and y <= 29 : 1
Valid = True
except :
Valid = False
island.DigHole(x, y) 1
return

© UCLES 2017 Page 16 of 19


9608/42 Cambridge International AS/A Level – Mark Scheme 491
May/June 2017
PUBLISHED
Question Answer Marks
Example Pascal
procedure StartDig;
var xString, yString : String;
x, y : integer;
begin
Valid := False;
repeat
Write('position down <0 to 9>? '); ReadLn(xString); 1
try
x := StrToInt(xString);
if (x >= 0) AND (x <= 9) 1
then
Valid := True;
except
Valid := False;
until Valid;
Valid := False;
repeat
Write(position across <0 to 29> ? '); ReadLn(yString); 1
try
y := StrToInt(yString);
if (y >= 0) AND (y <= 29) 1
then
Valid := True;
except
Valid := False;
until Valid; 1
island.DigHole(x,y); 1
end;

© UCLES 2017 Page 17 of 19


9608/42 Cambridge International AS/A Level – Mark Scheme 492
May/June 2017
PUBLISHED
Question Answer Marks
Example VB.NET
Sub StartDig()
Dim x, y As Integer
Dim Valid = False
Do
Console.Write("Position down <0 to 9>? ")
Try
x = CInt(Console.ReadLine()) 1
If (x >= 0) AND (x <= 9) Then 1
Valid = True
End If
Catch
Valid = False 'accept different types of exceptions
End Try
Loop Until Valid
Valid = False
Do
Console.Write("Position across <0 to 29> ? ")
Try
y = int(Console.ReadLine()) 1
If (y >= 0) AND (y <= 29) Then 1
Valid = True
End IF
Catch
Valid = False
End Try
Loop until Valid 1
island.DigHole(x, y) 1
End Sub

3(f)(i) containment/aggregation 1

© UCLES 2017 Page 18 of 19


9608/42 Cambridge International AS/A Level – Mark Scheme 493
May/June 2017
PUBLISHED
Question Answer Marks
3(f)(ii) • IslandClass box and Square Box, with correct connection Max 2
• One at IslandClass and one .. * at Square

© UCLES 2017 Page 19 of 19

Das könnte Ihnen auch gefallen