493
A- Level Computer Science 9608 2015 to 2017 Past Papers & Mark Schemes Compiled by: M Mushtaq Hussain 03215275281 1

A- Level Computer Science 9608 - Iteachiteach.pk/wp-content/uploads/2017/04/A2-computer-science-upto-2017.pdf · 9608 computer science 9608/32 Paper 3 (Written paper), maximum raw

  • Upload
    others

  • View
    62

  • Download
    3

Embed Size (px)

Citation preview

A- Level

Computer Science 9608

2015 to 2017 Past Papers & Mark Schemes

Compiled by: M Mushtaq Hussain 03215275281

1

This document consists of 12 printed pages.

DC (FD) 110069© UCLES 2015 [Turn over

Cambridge International ExaminationsCambridge International Advanced Level

*4

62

20

48

36

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.

2

2

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

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

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

VariableAssignment statement

Variable

Letter

= Variable Operator Variable

a

b

c

d

;

Letter Letter Letter

Operator+

÷

(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]

3

3

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

(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]

4

4

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

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

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

Description Term

AUnsolicited emails containing advertising material sent to a distribution list. ...........................

BA standalone piece of malicious software that can reproduce 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]

5

5

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

(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]

6

6

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

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]

7

7

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

(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]

8

8

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

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

A

B

X

A BWorking space

X

0 0

0 1

1 0

1 1 [1]

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

A

B

X

A BWorking space

X

0 0

0 1

1 0

1 1 [1]

9

9

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

(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

X

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

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

Show all your working.

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

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

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

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

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

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

10

10

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

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).

11

11

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

(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]

12

12

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

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 server

HTTP

email is transferred from one email server to another email server

POP3

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.

13

® IGCSE is the registered trademark of Cambridge International Examinations.

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.

14

Page 2 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2015 9608 32

© Cambridge International Examinations 2015

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

(ii) ‘2’ is not a variable 1

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

(b) <assignment statement> ::=

<variable> =

<variable><operator><variable>;

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

|<letter><letter><letter>

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

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

2

2

1

1

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

2

(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 // difficult to reverse-engineer

1

Total: 13

2 (a) • Spam

• Worm Pharming redirect website to fake website // domain name server compromised // proxy server compromised Phishing through email attempt to obtain somebody’s confidential data / install malware

1 1

1

1

(b) Spam

• user’s inbox is filled by large amount of unwanted email

• user / email server employs filtering software that can divert / delete spam email

Worm

• could corrupt user’s computer // delete data // consume bandwidth

• run anti-virus software in the background // not connect to the Internet // keep OS up-to-date

1 1 or 1

1

15

Page 3 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2015 9608 32

© Cambridge International Examinations 2015

(c) encryption: process of turning plain text into cipher text 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

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

• receiver is in possession of sender’s public key

• the received hash total / digital signature is decrypted with public key (SH)

• the receiver hashes received software (RH)

• If SH matches RH then software is authentic and has not been altered

Any four points 1

mark each

Total: 13

3 (a) (i) enumerated 1

(ii) record 1

(iii) MyMonthOfBirth � DateOfBirth.ThisMonth 1

(b) (i) TYPE LocationRainfall

DECLARE LocationName : STRING

DECLARE LocationHeight : INTEGER

DECLARE TotalMonthlyRainfall : ARRAY[1..12] OF REAL

ENDTYPE

1 1 1

1 +1

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

• only a small file so searching will require little processing

• new records can easily be appended

1 1 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

16

Page 4 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2015 9608 32

© Cambridge International Examinations 2015

(ii) Circuit 2

A B X

0 0 1

0 1 1

1 0 1

1 1 0

1

(b) (i) • circuit 1: BA.

• circuit 2: A + B

1

1

(ii) ≡BA. A + B 1

(c) BBA .)( +

Mark as follows:

)( BA+

B.

bar over whole expression

1 1 1

(d) BBA .)( +

= )( BA+ + B

= BBA ++ )(

= )( BBA ++

= 1+A =1 allow f.t. from (c)

1

1

1

1

1

[max 3]

Total: 11

5 (a) Monitoring system 1

(b) • temperature sensor …

• transmits measured temperature

• analogue to digital converter …

• converts analogue signal from sensor to digital value that can be stored

• storage device // data logger…

• for recording readings from sensor

• transmission hardware …

• to transfer data from sensor to storage device

• processor …

• to process incoming data

1 1 1 1 1 1 1 1 1 1

[max 6]

17

Page 5 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2015 9608 32

© Cambridge International Examinations 2015

(c) (i) temperature reading in location 5 has been processed

1 1

(ii) 0100 0000 1111 1011 1 mark per byte

2

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

1 mark for AND, 1 mark for address mode, 1 mark for mask, 1 mark for

indication of numbering system

1 + 1 + 1 + 1

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

1 mark for OR, 1 mark for mask 1 +1

Total: 17

6 (a) Description Protocol used

email client downloads an

email from an email server

HTTP

email is transferred from one email server to another email server

POP3

email client sends email to email server

SMTP

browser sends a request for a web page to a web server

1 mark for correct arrow from each description

(b) peer-to-peer 1

(c) (i) Tracker: central server that: stores details of other computers that have all / part of file to be downloaded // has data on those peers downloading and uploading file // shares IP addresses with other clients in swarm allowing them to connect

1

1

(ii) Seed: peer computer that has 100% of file // is uploading downloaded content

1 1

(iii) Swarm: all the connected peer computers that have all or part of the file to be downloaded / uploaded // share a torrent

1

1

Total: 11

18

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

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

Cambridge International ExaminationsCambridge International Advanced Level

*4

44

97

90

33

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.

19

2

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

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

VariableAssignment statement

Variable

Digit

:= Variable Operator Number

1

2

3

5

4

Letter Number

NumberDigit

LetterA

B

C

Operator+

/

20

3

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

(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]

21

4

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

(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]

22

5

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

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 may be part of a message for itself

Bus with terminators at each end

Connection provided through an access point Star

A process for handling collisions has to be implemented

Wireless

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]

23

6

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

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

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

Description Term

ASending emails which contain a link to a website that attempts to trick users into giving confidential personal data. .....................................

BIt replicates by inserting itself into another piece of 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]

24

7

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

(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]

25

8

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

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]

26

9

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

(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]

27

10

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

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

A

B

X

A BWorking space

X

0 0

0 1

1 0

1 1

[1]

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

A

B

X

A BWorking space

X

0 0

0 1

1 0

1 1

[1]

28

11

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

(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

X

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

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

Show all your working.

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

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

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

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

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

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

29

12

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

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]

30

13

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

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

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

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

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

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

Question 6 continues on page 14.

31

14

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

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]

32

® IGCSE is the registered trademark of Cambridge International Examinations.

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.

33

Page 2 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2015 9608 33

© Cambridge International Examinations 2015

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>

<variable> ::= <letter><number>

<number> ::= <digit>| <digit><number>

<letter> ::= A|B|C

<digit> ::= 1|2|3|4|5

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

1 + 1

1 1 + 1

1

(c) (i) Use of software … (idea of using) to implement a hardware set-up (idea of implementing / simulating / emulating)

1 1

(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 receives may be part of a message for that computer

bus with terminators at

each end

connection provided through an access point

star

a process for handling collisions has to be implemented

wireless

listening computer only receives packets that are addressed to this computer

1 mark for correct arrow(s) from each description

1

1

1

1

(b) (i) Server: central computer stores files that are to be downloaded

1 1

34

Page 3 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2015 9608 33

© Cambridge International Examinations 2015

(ii) Command: user can send action/instruction (or by example, e.g. change directory) that are carried out on server

1

1

(iii) Anonymous: allows user to access files user does not need to identify themselves to server

1 1

Total: 10

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

1 1 1 1

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

1 1 or 1 1

(c) cipher text: encrypted text which is not understandable 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

1

(d) • Manager encrypts email

• using public key of colleague

• colleague decrypts email

• using his/her private key

1 1 1 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

DECLARE Latitude : REAL

DECLARE Temperature : ARRAY[1..15] OF INTEGER

ENDTYPE

1 1

1 + 1 1

(ii) StationID is hashed to produce home location

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

1 1 1

Total: 11

35

Page 4 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2015 9608 33

© Cambridge International Examinations 2015

5 (a) (i)

Circuit 1

A B X

0 0 1

0 1 0

1 0 0

1 1 0

1

(ii)

Circuit 2

A B X

0 0 1

0 1 0

1 0 0

1 1 0

1

(b) (i) circuit 1 BA+

circuit 2 A .B

1 1

(ii) ≡+ BA A . B

1

(c) BBA +).(

mark as :

).( BA

B+ bar over whole expression

1 1 1

(d) BBA +).(

= ).( BA . B

= BBA )..(

= )..( BBA

= 0.A

=0

allow f.t. from (c)

1

1

1

1

1

max 3

Total: 11

36

Page 5 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2015 9608 33

© Cambridge International Examinations 2015

6 (a) Control system 1

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

1 1 1 1 1

1 1 1 1 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 interval

1

(iii) reading from sensor is compared with parameter appropriate action is taken (by example)

2

(d) (i) reading available for processing reading value is 4

1 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

37

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

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

Cambridge International ExaminationsCambridge International Advanced Level

*1

91

20

82

94

2*

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.

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.

38

2

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

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

RemindersThe 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)

39

3

© UCLES 2015 [Turn over9608/43/PRE/M/J/15

TASK 1

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

• create linked list• add item to linked list• remove item from linked list

Key focus: Linked lists

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.1Consider the use of a linked list to store names in alphabetical order.

The following sequence of operations is carried out:

CreateLinkedListAddName("Nabila")AddName("Jack")AddName("Kerrie")AddName("Sara")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:

Key focus: Conceptualdiagrams of linked lists

40

4

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

TASK 1.2The 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.

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.

Key focus: Implementation oflinked lists using an array of records

41

5

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

TASK 1.3Complete 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]

42

6

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

TASK 1.4Complete 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 list03 NameList[FreePointer].Name ← NewName04 NewNodePointer ← FreePointer05 FreePointer ← NameList[FreePointer].Pointer0607 // initialise current pointer to start of list08 CurrentPointer ← HeadPointer0910 // check that it is not the special case of adding to empty list11 IF HeadPointer > 012 // loop to locate position of new name13 // saves current pointer and then updates current pointer14 WHILE NameList[CurrentPointer].Name < NewName15 PreviousPointer ← CurrentPointer16 CurrentPointer ← NameList[CurrentPointer].Pointer17 ENDWHILE18 ENDIF1920 // check to see whether new name is first in linked list21 // if first item then place item at head of list22 // if not first item then adjust pointers to place it in correct 23 // position in list24 IF CurrentPointer = HeadPointer25 THEN26 NameList[NewNodePointer].Pointer ← HeadPointer27 HeadPointer ← NewNodePointer28 ELSE29 NameList[NewNodePointer].Pointer ← NameList[PreviousPointer].Pointer30 NameList[PreviousPointer].Pointer ← NewNodePointer31 ENDIF32 ENDPROCEDURE

43

7

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

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

TASK 1.6The 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.1Write the algorithm, as a procedure in pseudocode, from the structured English given above.

TASK 1.6.2Write program code from your pseudocode design.

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

Suggested extension taskQueues, stacks, binary trees and dictionaries can be implemented as linked lists of nodes.

Design pseudocode and write program code for these data structures.

44

8

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

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• Truck

Key focus: Object-oriented programming

TASK 2.1Complete the inheritance diagram.

45

9

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

TASK 2.2Complete 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.3Write program code for the class definitions. Make use of polymorphism and inheritance where appropriate.

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

Suggested extension taskWrite program code to display the properties of the object you created in Task 2.4.

46

10

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

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 diagramsComplete the diagram.

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

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

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

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

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

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

47

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

DC (RW) 107191© UCLES 2015 [Turn over

Cambridge International ExaminationsCambridge International Advanced Level

*8

35

55

93

50

2*

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.

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.

48

2

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

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

RemindersThe 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)

49

3

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

TASK 1

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

• create linked list• add item to linked list• remove item from linked list

Key focus: Linked lists

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.1Consider the use of a linked list to store names in alphabetical order.

The following sequence of operations is carried out:

CreateLinkedListAddName("Nabila")AddName("Jack")AddName("Kerrie")AddName("Sara")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:

Key focus: Conceptualdiagrams of linked lists

50

4

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

TASK 1.2The 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.

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.

Key focus: Implementation oflinked lists using an array of records

51

5

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

TASK 1.3Complete 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]

52

6

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

TASK 1.4Complete 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 list03 NameList[FreePointer].Name ← NewName04 NewNodePointer ← FreePointer05 FreePointer ← NameList[FreePointer].Pointer0607 // initialise current pointer to start of list08 CurrentPointer ← HeadPointer0910 // check that it is not the special case of adding to empty list11 IF HeadPointer > 012 // loop to locate position of new name13 // saves current pointer and then updates current pointer14 WHILE NameList[CurrentPointer].Name < NewName15 PreviousPointer ← CurrentPointer16 CurrentPointer ← NameList[CurrentPointer].Pointer17 ENDWHILE18 ENDIF1920 // check to see whether new name is first in linked list21 // if first item then place item at head of list22 // if not first item then adjust pointers to place it in correct 23 // position in list24 IF CurrentPointer = HeadPointer25 THEN26 NameList[NewNodePointer].Pointer ← HeadPointer27 HeadPointer ← NewNodePointer28 ELSE29 NameList[NewNodePointer].Pointer ← NameList[PreviousPointer].Pointer30 NameList[PreviousPointer].Pointer ← NewNodePointer31 ENDIF32 ENDPROCEDURE

53

7

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

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

TASK 1.6The 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.1Write the algorithm, as a procedure in pseudocode, from the structured English given above.

TASK 1.6.2Write program code from your pseudocode design.

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

Suggested extension taskQueues, stacks, binary trees and dictionaries can be implemented as linked lists of nodes.

Design pseudocode and write program code for these data structures.

54

8

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

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• Truck

Key focus: Object-oriented programming

TASK 2.1Complete the inheritance diagram.

55

9

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

TASK 2.2Complete 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.3Write program code for the class definitions. Make use of polymorphism and inheritance where appropriate.

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

Suggested extension taskWrite program code to display the properties of the object you created in Task 2.4.

56

10

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

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 diagramsComplete the diagram.

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

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

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

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

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

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

57

This document consists of 16 printed pages.

DC (SLM) 108502© UCLES 2015 [Turn over

Cambridge International ExaminationsCambridge International Advanced Level

*0

58

49

67

12

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.

58

2

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

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 ...........................................................................................................................

59

3

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

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]

60

4

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

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]

61

5

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

(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]

62

6

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

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.

Co

nd

itio

ns

goods totalling more than $20

Y Y Y Y N N N N

goods totalling more than $100

Y Y N N Y Y N N

have discount card Y N Y N Y N Y N

Act

ion

s

No discount

5% discount

10% discount

[4]

(b) Simplify your solution by removing redundancies.

Co

nd

itio

ns

goods totalling more than $20

goods totalling more than $100

have discount card

Act

ion

s

No discount

5% discount

10% discount

[5]

63

7

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

(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]

64

8

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

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]

65

9

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

(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]

66

10

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

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]

67

11

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

(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]

68

12

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

69

13

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

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]

70

14

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

(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]

71

15

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

(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

72

16

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

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.

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]

73

® IGCSE is the registered trademark of Cambridge International Examinations.

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.

74

Page 2 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2015 9608 42

© Cambridge International Examinations 2015

1

locked unlocked

push

Attempt to

insert coin

Pass throughstart

Insert coin

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]

75

Page 3 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2015 9608 42

© Cambridge International Examinations 2015

3 (a)

Co

nd

itio

ns

goods totalling more than $20

Y Y Y Y N N N N

goods totalling more than $100

Y Y N N Y Y N N

have discount card Y N Y N Y N Y N

Ac

tio

ns

No discount X X X X X

5% discount X X

10% discount X

1 mark

1 mark

1 mark

1 mark

[4] (b)

Co

nd

itio

ns

goods totalling more than $20

Y Y Y Y N

goods totalling more than $100

Y Y N N -

have discount card Y N Y N -

Ac

tio

ns

No discount X X

5% discount X X

10% discount X

1 mark per column [5]

76

Page 4 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2015 9608 42

© Cambridge International Examinations 2015

(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]

77

Page 5 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2015 9608 42

© Cambridge International Examinations 2015

4 (a)

[3]

78

Page 6 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2015 9608 42

© Cambridge International Examinations 2015

(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]

79

Page 7 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2015 9608 42

© Cambridge International Examinations 2015

(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]

80

Page 8 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2015 9608 42

© Cambridge International Examinations 2015

(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]

81

Page 9 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2015 9608 42

© Cambridge International Examinations 2015

(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]

82

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

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

Cambridge International ExaminationsCambridge International Advanced Level

*7

88

10

70

89

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.

83

2

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

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 ...........................................................................................................................

84

3

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

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]

85

4

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

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]

86

5

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

(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]

87

6

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

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.

Co

nd

itio

ns Age under 25 Y Y Y Y N N N N

Previous accident Y Y N N Y Y N N

Licence held for 3 or more years

Y N Y N Y N Y N

Act

ion

s

10% extra charge

No discount

5% discount

[6]

(b) Simplify your solution by removing redundancies.

Co

nd

itio

ns Age under 25

Previous accident

Licence held for 3 or more years

Act

ion

s

10% extra charge

No discount

5% discount

[3]

88

7

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

(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]

89

8

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

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

90

9

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

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]

91

10

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

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]

92

11

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

(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]

93

12

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

(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

94

13

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

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]

95

14

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

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 number

n (n = 0) OR (n = 1) n DIV 2 n MOD 2

1 40 FALSE 20

2

3

4

5

6

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

96

15

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

(d) State the process that is carried out by procedure X.

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

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

(e) Write program code for procedure X.

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

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

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

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

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

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

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

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

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

97

® IGCSE is the registered trademark of Cambridge International Examinations.

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.

98

Page 2 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2015 9608 43

© Cambridge International Examinations 2015

1

Pump ready Pump in use

Replace nozzle

Press trigger

start

Take nozzle

Pump out of usePump dispensing

Stop pressing triggerReset pump display

[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]

99

Page 3 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2015 9608 43

© Cambridge International Examinations 2015

3 (a) C

on

dit

ion

s

Age under 25 Y Y Y Y N N N N

Previous accident Y Y N N Y Y N N

Licence held for 3 or more years

Y N Y N Y N Y N

Ac

tio

ns

10% extra cost X

No discount X X X X

5% discount X X X

1 mark

1 mark

1 mark

1 mark

1 mark 1 mark

[6] (b)

Co

nd

itio

ns

Age under 25 Y Y Y Y N N

Previous accident Y Y N N Y N

Licence held for 3 or more years

Y N Y N - -

Ac

tio

ns

10% extra cost X

No discount X X X

5% discount X X

1 mark

1 mark

1 mark

[3]

100

Page 4 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2015 9608 43

© Cambridge International Examinations 2015

(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;

101

Page 5 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2015 9608 43

© Cambridge International Examinations 2015

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;

102

Page 6 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2015 9608 43

© Cambridge International Examinations 2015

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]

103

Page 7 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2015 9608 43

© Cambridge International Examinations 2015

(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)

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]

Top of Stack

104

Page 8 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2015 9608 43

© Cambridge International Examinations 2015

(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]

105

Page 9 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2015 9608 43

© Cambridge International Examinations 2015

(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]

106

Page 10 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2015 9608 43

© Cambridge International Examinations 2015

(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]

107

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

DC (ST) 95544/3© UCLES 2015 [Turn over

Cambridge International ExaminationsCambridge International Advanced Level

*6

55

00

85

96

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.

108

2

9608/32/O/N/15© UCLES 2015

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]

109

3

9608/32/O/N/15© UCLES 2015 [Turn over

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]

110

4

9608/32/O/N/15© UCLES 2015

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.

SymbolToken

Value Type

Start 60 Variable

0.1 61 Constant

[3]

111

5

9608/32/O/N/15© UCLES 2015 [Turn over

(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]

112

6

9608/32/O/N/15© UCLES 2015

(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]

113

7

9608/32/O/N/15© UCLES 2015 [Turn over

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]

114

8

9608/32/O/N/15© UCLES 2015

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 parallel processing.

SIMD

The processor has several ALUs. Each ALU executes the same instruction but on different data.

MISD

There are several processors. Each processor executes different instructions drawn from a common pool. Each processor operates on different data drawn from a common pool.

SISD

There is only one processor executing one set of instructions on a single set of data.

MIMD

[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]

115

9

9608/32/O/N/15© UCLES 2015 [Turn over

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

R0

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]

116

10

9608/32/O/N/15© UCLES 2015

(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]

117

11

9608/32/O/N/15© UCLES 2015

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]

118

® IGCSE is the registered trademark of Cambridge International Examinations.

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.

119

Page 2 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 32

© Cambridge International Examinations 2015

1 (a) (i) 01101000 0011 = 0.1101 (or 1/2 + 1/4 + 1/16) × 2�3 [1+1] = 110.1 = 6.5 [1] (ii) +3.5 = 11.1 [1] = 0.111 × 2�2 (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)

[1]

[1+1]

Symbol Token

Value Type

Start 60 Variable

0.1 61 Constant

Counter 62 Variable

10 63 Constant

120

Page 3 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 32

© Cambridge International Examinations 2015

(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]

121

Page 4 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 32

© Cambridge International Examinations 2015

[Total: 11] 4 (a) 1 mark for correct arrow from each description

Description

Computer Architecture

A computer that does not have the ability for parallel processing

SIMD

The processor has several ALUs. Each ALU executes the same instruction but on different data.

MISD

There are several processors. Each processor executes different instructions drawn from a common pool. Each processor operates on different data drawn from a common pool.

SISD

There is only one processor executing one set of instructions on a single set of data.

MIMD

[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]

122

Page 5 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 32

© Cambridge International Examinations 2015

5 (a) (i)

+ R.QP.=Z [1]

+ .RQ.P [1]

P.Q.R [1] (ii)

PQ

00 01 11 10

R 0 0 0 0 1

1 0 0 1 1

[1] (iii) 1 mark each loop

PQ

00 01 11 10

R0 0 0 0 1

1 0 0 1 1

Allow f.t. from (ii) [2] (iv)

=Z

Q.P [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

RS

00 0 0 0 0

01 0 1 1 1

11 0 1 1 0

10 0 0 0 0

[4]

123

Page 6 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 32

© Cambridge International Examinations 2015

(ii) 1 mark for loop with two 1s; 1 mark for loop with four 1s

PQ

00 01 11 10

RS

00 0 0 0 0

01 0 1 1 1

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]

SP.R.+ [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]

124

This document consists of 12 printed pages.

DC (NH) 117457© UCLES 2015 [Turn over

*8

50

94

80

50

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.

Cambridge International ExaminationsCambridge International Advanced Level

125

2

9608/33/O/N/15© UCLES 2015

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]

126

3

9608/33/O/N/15© UCLES 2015 [Turn over

(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]

127

4

9608/33/O/N/15© UCLES 2015

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.

SymbolToken

Value Type

Counter 60 Variable

1.5 61 Constant

[3]

128

5

9608/33/O/N/15© UCLES 2015 [Turn over

(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]

129

6

9608/33/O/N/15© UCLES 2015

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]

130

7

9608/33/O/N/15© UCLES 2015 [Turn over

(e) Name an application for which the method identified in part (d) is an appropriate solution. Justify your choice.

Application ................................................................................................................................

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

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

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

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

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

131

8

9608/33/O/N/15© UCLES 2015

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 general purpose registers

RISC

Many addressing modes are available

CISC

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]

132

9

9608/33/O/N/15© UCLES 2015 [Turn over

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

C0

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]

133

10

9608/33/O/N/15© UCLES 2015

(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]

134

11

9608/33/O/N/15© UCLES 2015 [Turn over

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]

135

12

9608/33/O/N/15© UCLES 2015

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.

(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]

136

® IGCSE is the registered trademark of Cambridge International Examinations.

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.

137

Page 2 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 33

© Cambridge International Examinations 2015

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)

Symbol

Token

Value Type

Counter 60 variable

1.5 61 constant

Num1 62 variable [1]

5.0 63 constant [1+1]

(b)

60

01

61

51

62

4A

60

03

62

4B

62

01

62

02

63

4C

[1+1]

138

Page 3 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 33

© Cambridge International Examinations 2015

(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]

139

Page 4 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 33

© Cambridge International Examinations 2015

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]

140

Page 5 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 33

© Cambridge International Examinations 2015

5 (a) (i) A .B.C + [1]

A.B.C [1]

+ A.B.C [1] (ii)

AB

00 01 11 10

C

0 0 0 1 0

1 0 1 1 0 [1]

(iii)

AB

00 01 11 10

C

0 0 0 1 0 1 mark for each loop

1 0 1 1 0

Allow f.t. from (ii) [2] (iv) X = A.B [1]

+ B.C [1] Allow f.t. from (iii)

141

Page 6 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 33

© Cambridge International Examinations 2015

(b) (i)

AB

00 01 11 10

1 mark row headings

1 mark column headings

1 mark per 2 correct rows (based on headings)

CD

00 0 1 1 0

01 0 0 0 0

11 0 0 1 0

10 0 1 1 0

[4] (ii)

AB

00 01 11 10

CD

00 0 1

1 0 1 mark for loop with two 1s

1 mark for looping the four 1s01 0 0 0 0

11 0 0 1

0

10 0 1 1 0

[2] (iii) X = B.D [1]

+ A.B.C [1]

142

Page 7 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 33

© Cambridge International Examinations 2015

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]

143

This document consists of 9 printed pages and 3 blank pages.

DC (NH/SW) 111478© UCLES 2015 [Turn over

Cambridge International ExaminationsCambridge International Advanced Level

*3

42

40

18

74

3*

COMPUTER SCIENCE 9608/42

Paper 4 Further Problem-solving and Programming Skills October/November 2015

PRE-RELEASE MATERIAL

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.

144

2

9608/42/PRE/O/N/15© UCLES 2015

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

145

3

9608/42/PRE/O/N/15© UCLES 2015 [Turn over

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

TASK 1.1Complete the inheritance diagram.

Key focus: Object-oriented Programming

146

4

9608/42/PRE/O/N/15© UCLES 2015

TASK 1.2Complete 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.3Write program code for the class definitions. Make use of polymorphism and inheritance where appropriate.

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

Suggested extension taskWrite program code to display the properties of the object you created in Task 1.4.

147

5

9608/42/PRE/O/N/15© UCLES 2015 [Turn over

TASK 2

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.1The 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.2The 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.

2

51 3 4

Note: the arrow denotes a dummy activity.

Write the critical path.

Calculate the shortest time (in days) before the client can start acceptance testing.

Key focus: Project management using PERT and GANTT charts

Key focus: Project management using a PERT chart

148

6

9608/42/PRE/O/N/15© UCLES 2015

TASK 2.3Another proposal is to deploy four programmers, who each carry out their own module testing.

TASK 2.3.1Draw a GANTT chart for this proposal.

Activity

Hour number 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

TASK 2.3.2If the programmers each work 10 hours a day, calculate how many days it takes before the customer can start acceptance testing.

Suggested extension taskTry other proposals, such as only a software tester can carry out any testing.

ActivityCode P1

Test P1Code P2

Test P2Code P3

Test P3Code P4

Test P4Code P5

Test P5Code P6

Test P6Code P7

Test P7Code P8

Test P8Integration testing

Alpha testing

Hour number 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

Key focus: Project management using a GANTT chart

149

7

9608/42/PRE/O/N/15© UCLES 2015 [Turn over

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

ENDFUNCTION

The Hash function assumes the existence of the function LeftToInt, defined below:

LeftToInt(ThisString : STRING, n: INTEGER) RETURNS INTEGERreturns 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.1Write program code to implement the functions LeftToInt and Hash.

Key focus: Random files

150

8

9608/42/PRE/O/N/15© UCLES 2015

TASK 3.2Write 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.3Write 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.4You 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.

151

9

9608/42/PRE/O/N/15© UCLES 2015

TASK 3.5

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.6Add 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.7The 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 taskWrite 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.

Key focus: Exception handling

152

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

DC (AC) 95228/3© UCLES 2015 [Turn over

Cambridge International ExaminationsCambridge International Advanced Level

*9

91

09

55

72

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.

153

2

9608/42/O/N/15© UCLES 2015

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.

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

(a) From this data a GANTT chart is constructed.

Activity

ABCDEFGHJKLMN

Week number 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

154

3

9608/42/O/N/15© UCLES 2015 [Turn over

(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

ABCDEFGHJKLMN

Week number 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

[9]

(ii) State the new estimated completion date.

Week number ................................................................................................................ [1]

155

4

9608/42/O/N/15© UCLES 2015

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]

156

5

9608/42/O/N/15© UCLES 2015 [Turn over

(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]

157

6

9608/42/O/N/15© UCLES 2015

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.

StudentStudentName: STRING

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

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

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

ShowStudentName()

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

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

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

FullTimeStudent PartTimeStudentAddress: STRING

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

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

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

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

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

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

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

Constructor()

ShowAddress()

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

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

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

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

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

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

[7]

158

7

9608/42/O/N/15© UCLES 2015 [Turn over

(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]

159

8

9608/42/O/N/15© UCLES 2015

(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]

160

9

9608/42/O/N/15© UCLES 2015 [Turn over

(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")

DictionaryIndex 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]

161

10

9608/42/O/N/15© UCLES 2015

(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]

162

11

9608/42/O/N/15© UCLES 2015 [Turn over

Question 5 begins on page 12.

163

12

9608/42/O/N/15© UCLES 2015

5 The table shows assembly language instructions for a processor which has one general purpose register – the Accumulator (ACC).

InstructionExplanation

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

164

13

9608/42/O/N/15© UCLES 2015 [Turn over

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]

165

14

9608/42/O/N/15© UCLES 2015

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]

166

15

9608/42/O/N/15© UCLES 2015

(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]

167

® IGCSE is the registered trademark of Cambridge International Examinations.

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.

168

Page 2 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 42

© Cambridge International Examinations 2015

1 (a) (i) Activity

A

B

C

D

E

F

G

H

J

K

L

M

N

Week Number 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

1 mark for each square [2] (ii) week number 18 Allow follow through [1]

169

Page 3 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 42

© Cambridge International Examinations 2015

(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 Number

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

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]

170

Page 4 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 42

© Cambridge International Examinations 2015

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

171

Page 5 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 42

© Cambridge International Examinations 2015

3 (a)

Student

StudentName : STRING DateOfBirth : DATETIME ……………………………………………………………………………………… ShowStudentName() ShowDateOfBirth() ………………………………………………………………………………………

FullTimeStudent PartTimeStudent

Address: STRING TelephoneNumber : STRING ………………………………………………………………………………………

NumberOfCourses : INTEGER Fee : Currency FeePaid : BOOLEAN

Constructor() ShowAddress() ShowTelephoneNumber() ………………………………………………………………………………………

Constructor()ShowNumberOFCourses() 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]

172

Page 6 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 42

© Cambridge International Examinations 2015

(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]

173

Page 7 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 42

© Cambridge International Examinations 2015

(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]

174

Page 8 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 42

© Cambridge International Examinations 2015

(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]

175

Page 9 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 42

© Cambridge International Examinations 2015

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]

176

Page 10 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 42

© Cambridge International Examinations 2015

(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]

177

Page 11 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 42

© Cambridge International Examinations 2015

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]

178

Page 12 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 42

© Cambridge International Examinations 2015

(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]

179

This document consists of 9 printed pages and 3 blank pages.

DC (NH/SW) 111426© UCLES 2015 [Turn over

Cambridge International ExaminationsCambridge International Advanced Level

*7

21

36

96

10

8*

COMPUTER SCIENCE 9608/43

Paper 4 Further Problem-solving and Programming Skills October/November 2015

PRE-RELEASE MATERIAL

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.

180

2

9608/43/PRE/O/N/15© UCLES 2015

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

181

3

9608/43/PRE/O/N/15© UCLES 2015 [Turn over

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

TASK 1.1Complete the inheritance diagram.

Key focus: Object-oriented Programming

182

4

9608/43/PRE/O/N/15© UCLES 2015

TASK 1.2Complete 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.3Write program code for the class definitions. Make use of polymorphism and inheritance where appropriate.

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

Suggested extension taskWrite program code to display the properties of the object you created in Task 1.4.

183

5

9608/43/PRE/O/N/15© UCLES 2015 [Turn over

TASK 2

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.1The 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.2The 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.

2

51 3 4

Note: the arrow denotes a dummy activity.

Write the critical path.

Calculate the shortest time (in days) before the client can start acceptance testing.

Key focus: Project management using PERT and GANTT charts

Key focus: Project management using a PERT chart

184

6

9608/43/PRE/O/N/15© UCLES 2015

TASK 2.3Another proposal is to deploy four programmers, who each carry out their own module testing.

TASK 2.3.1Draw a GANTT chart for this proposal.

Activity

Hour number 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

TASK 2.3.2If the programmers each work 10 hours a day, calculate how many days it takes before the customer can start acceptance testing.

Suggested extension taskTry other proposals, such as only a software tester can carry out any testing.

ActivityCode P1

Test P1Code P2

Test P2Code P3

Test P3Code P4

Test P4Code P5

Test P5Code P6

Test P6Code P7

Test P7Code P8

Test P8Integration testing

Alpha testing

Hour number 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

Key focus: Project management using a GANTT chart

185

7

9608/43/PRE/O/N/15© UCLES 2015 [Turn over

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

ENDFUNCTION

The Hash function assumes the existence of the function LeftToInt, defined below:

LeftToInt(ThisString : STRING, n: INTEGER) RETURNS INTEGERreturns 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.1Write program code to implement the functions LeftToInt and Hash.

Key focus: Random files

186

8

9608/43/PRE/O/N/15© UCLES 2015

TASK 3.2Write 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.3Write 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.4You 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.

187

9

9608/43/PRE/O/N/15© UCLES 2015

TASK 3.5

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.6Add 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.7The 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 taskWrite 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.

Key focus: Exception handling

188

This document consists of 16 printed pages.

DC (KN/SW) 115643© UCLES 2015 [Turn over

Cambridge International ExaminationsCambridge International Advanced Level

*4

09

52

09

13

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.

189

2

9608/43/O/N/15© UCLES 2015

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.

Activity Description Weeks to 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.

10

4 8

1 2 3 5 6 73F

5A

10J

9

(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]

190

3

9608/43/O/N/15© UCLES 2015 [Turn over

(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]

191

4

9608/43/O/N/15© UCLES 2015

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]

192

5

9608/43/O/N/15© UCLES 2015 [Turn over

(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]

193

6

9608/43/O/N/15© UCLES 2015

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.

StockItemTitle: STRING

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

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

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

ShowTitle()

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

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

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

Book CDAuthor: STRING

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

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

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

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

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

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

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

Constructor()

ShowAuthor()

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

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

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

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

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

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

[7]

194

7

9608/43/O/N/15© UCLES 2015 [Turn over

(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]

195

8

9608/43/O/N/15© UCLES 2015

(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]

196

9

9608/43/O/N/15© UCLES 2015 [Turn over

Question 4 begins on page 10.

197

10

9608/43/O/N/15© UCLES 2015

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.

CreateTreeAdd("Dodi")Add("Farai")Add("Elli")Add("George")Add("Ben")Add("Celine")Add("Ali")

[4]

198

11

9608/43/O/N/15© UCLES 2015 [Turn over

(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]

199

12

9608/43/O/N/15© UCLES 2015

(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]

200

13

9608/43/O/N/15© UCLES 2015 [Turn over

Question 5 begins on page 14.

201

14

9608/43/O/N/15© UCLES 2015

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.

MembershipFileAddress 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]

202

15

9608/43/O/N/15© UCLES 2015 [Turn over

(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]

203

16

9608/43/O/N/15© UCLES 2015

(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.

204

® IGCSE is the registered trademark of Cambridge International Examinations.

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.

205

Page 2 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 43

© Cambridge International Examinations 2015

1 (a) (i)

A F

5

B C E G

5 15 5 53

[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]

206

Page 3 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 43

© Cambridge International Examinations 2015

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]

207

Page 4 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 43

© Cambridge International Examinations 2015

3 (a)

StockItem

Title: STRINGDateAcquired : TDATETIME……………………… OnLoan: BOOLEAN .……………………………………… ……………………………………………………………………………………… ShowTitle()ShowDateAcquired() …………………………………… ShowOnLoan() ………………………………………………… ………………………………………………………………………………………

Book CD

Author: STRING ISBN: STRING………………………………………… ………………………………………………………………………………………………………………………………………………………………………………

Artist: STRING …………………………………………… Playtime: INTEGER …………………………………… ………………………………………………………………………………………………………………………………………………………………………………

Constructor() ShowAuthor() ShowISBN()………………………………………………………… ………………………………………………………………………………………

Constructor()………………………………………………… ShowArtist() ………………………………………………… ShowPlayTime() …………………………………………… ………………………………………………………………………………………

[max. 7]

208

Page 5 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 43

© Cambridge International Examinations 2015

(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]

209

Page 6 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 43

© Cambridge International Examinations 2015

(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]

210

Page 7 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 43

© Cambridge International Examinations 2015

(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]

211

Page 8 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 43

© Cambridge International Examinations 2015

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]

212

Page 9 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 43

© Cambridge International Examinations 2015

(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]

213

Page 10 Mark Scheme Syllabus Paper

Cambridge International A Level – October/November 2015 9608 43

© Cambridge International Examinations 2015

(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]

214

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

DC (ST/AR) 126657© UCLES 2016 [Turn over

*6

94

88

41

83

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.

Cambridge International ExaminationsCambridge International Advanced Level

215

2

9608/32/M/J/16© UCLES 2016

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.

ComputerD

File server ComputerB

ComputerA

ComputerC

[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]

216

3

9608/32/M/J/16© UCLES 2016 [Turn over

(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]

217

4

9608/32/M/J/16© UCLES 2016

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 andother application data are sent. The key and data are encrypted usingthe 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]

218

5

9608/32/M/J/16© UCLES 2016 [Turn over

(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]

219

6

9608/32/M/J/16© UCLES 2016

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 system 1Guest operating

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]

220

7

9608/32/M/J/16© UCLES 2016 [Turn over

(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]

221

8

9608/32/M/J/16© UCLES 2016

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.

serial

sequential

random

File organisation method

direct

sequential

File access method

[4]

222

9

9608/32/M/J/16© UCLES 2016 [Turn over

(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]

223

10

9608/32/M/J/16© UCLES 2016

5 (a) Complete the truth table for this NAND gate:

A

B

X

A B X

0 0

0 1

1 0

1 1

[1]

A SR flip-flop is constructed using two NAND gates.

S

Q

R

Q

(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]

224

11

9608/32/M/J/16© UCLES 2016 [Turn over

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]

225

12

9608/32/M/J/16© UCLES 2016

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]

226

13

9608/32/M/J/16© UCLES 2016 [Turn over

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.

InstructionExplanation

Op code Operand

LDD <address> Direct addressing. Load the contents of the given 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)

ADD <address> Add the contents of the given address to the contents of ACC

AND <address> Bitwise AND operation of the contents of ACC with the contents of <address>

CMP #n Compare the contents of ACC with the number n

JMP <address> Jump to the given address

JPE <address> Following a compare instruction, jump to <address> if the compare was True

JGT <address>Following a compare instruction, jump to <address> if the content of ACC is greater than the number used in the compare instruction

END End the program and return to the operating system

227

14

9608/32/M/J/16© UCLES 2016

(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

228

15

9608/32/M/J/16© UCLES 2016

(i) Dry run the assembly language code. Start at LOOP and finish when EXIT is reached.

BITREG COUNT VALUE ACCB00001010 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]

229

® IGCSE is the registered trademark of Cambridge International Examinations.

This document consists of 6 printed pages.

© UCLES 2016 [Turn over

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.

230

Page 2 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2016 9608 32

© Cambridge International Examinations 2016

Question Answer Marks

1 (a) Single line joining all four computers and file server One “terminator” at each end

1 1

(b)

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.

1

1

1

(c) (i) Collision 1

(ii) Both stop transmitting Each uses a random time Wait for time period Check for bus status Attempt to re-transmit

1 1 1 1 1

Max 3

(d) Star topology created A switch has a number of ports Each connects to a single device (using a dedicated cable) Switch provides direct transmission/path from device to device Collisions are no longer possible There are dedicated links from Computer A to Computer C AND from the Server to Computer D

1 1 1 1 1 1

Max 4

2 (a) Examples: Serial number Certificate Authority that issued certificate CA digital signature Name of company/organisation/individual/subject/owner owning Certificate ‘Subject’ public key Period during which Certificate is valid // some relevant date

A mark for

each correct

data item –

Max 3

(b) (i) Public The individual keeps their private key private // the public key can be known by others (the public)

1

1

(ii) Public 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

1

231

Page 3 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2016 9608 32

© Cambridge International Examinations 2016

(iii) Private ‘Only’ the CA’s public key will allow decryption of the Certificate // proving the certificate was issued by the CA

1

1

(c) (i) Digital signature 1

(ii) Alexa’s digital certificate (Includes) Alexa’s public key Used to hash message received // produce message digest Generated hash compared to digital signature

1 1 1 1

Max 2

(iii) Examples: Financial transaction Legal document Software distribution

1 1 1

Max 2

3 (a) (i) Examples: Create / delete virtual machine Existing hardware made available to guest OS // hardware emulation Ensures each virtual machine is protected from actions of another virtual machine

1 1 1

Max 2

(ii) Guest operating system: An operating system running in a virtual machine // Controls virtual hardware // OS is being emulated 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 software Guest OS is running under the Host OS software

1

1

1

Max 2

(b) (i) Examples: Trial/use alternative replacement operating system(s) … Test to identify possible problems Much easier to create VM with a new OS than create new computer system Trial/use alternative replacement web server software … 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 (which does not disrupt the web server service)

Two marks

for each use

Maximum two uses

Max 4

232

Page 4 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2016 9608 32

© Cambridge International Examinations 2016

(ii) Examples: Using virtual machine means execution of extra code // emulation of some hardware … Non-VM installation may not perform in the same way Execution speed slower than non-VM system Problems in judging actual response times at time of maximum traffic needs fastest possible speed Particular hardware may be difficult to emulate

1

1 1 1 1

1 Max 2

4 (a)

File organisation method File access method

serial

direct

sequential

sequential

random

1

2

1

(b) (i) Sequential As all customers get statement … // high hit rate Suitable for batch processing of the records // the records will be processed one after the other File organised using customer’s unique ID (as primary key field) // Serial As all customers get statement … // high hit rate Suitable for batch processing of the records // the records will be processed one after the other Order not important

1 1

1 1

1 1

1 1

Max 3

(ii) Random Real-time transaction processing Requires fastest access to data No need to search through records

1 1 1 1

Max 3

233

Page 5 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2016 9608 32

© Cambridge International Examinations 2016

(iii) Serial Each new record is appended Transactions are recorded in chronological order File re-organisation not required for each new record // no need for the records to be sorted

1 1 1

Max 3

5 (a)

A B X

0 0 1

0 1 1

1 0 1

1 1 0

1

(b) (i)

S R Q Q

1 0 0 1

1 1 0 1

0 1 1 0

1 1 1 0

0 0 1 1

1

1

1

1

(ii) S = 0 R = 0 Produces Q = 1 , Q =1 // Q and Q have same value But Q and Q should be complements of each other Becomes unstable

1

1 1 1

Max 3

(c) (i) Clock (pulse) 1

(ii) All four possibilities are valid The 1-1 combination changes output to logical complement Unstable state avoided Invalid state cannot occur // the flip-flop is stable

1 1 1 1

Max 1

(d) Memory // data storage Stores a single bit

1 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

234

Page 6 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2016 9608 32

© Cambridge International Examinations 2016

(b) Examples: Pressure … If intruder steps on sensor Infra-red … If beam cut by intruder Motion / ultrasonic… Detects any movement in an area Contact / magnetic … If door / window opened

1 – sensor 1 – justification Maximum 2 sensors

Max 4

(c) (i)

BITREG COUNT VALUE ACC

B00001010 0 1 B00001010

B00000000

1

2 2

B00001010

B00000010

0

1 1

2

4 4

B00001010

B00000000

4

8 8

B00001010

B00001000

1

2 2

8

Mark as follows: 1 mark for: COUNT column VALUE column First two values in ACC column Rest of ACC column

Max 4

(ii) #1 1

(iii) CMP #8 CMP #128

1

1

235

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

DC (ST/AR) 126658© UCLES 2016 [Turn over

*7

65

67

17

08

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.

Cambridge International ExaminationsCambridge International Advanced Level

236

2

9608/33/M/J/16© UCLES 2016

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.

ComputerD

File server ComputerB

ComputerA

ComputerC

[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]

237

3

9608/33/M/J/16© UCLES 2016 [Turn over

(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]

238

4

9608/33/M/J/16© UCLES 2016

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 andother application data are sent. The key and data are encrypted usingthe 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]

239

5

9608/33/M/J/16© UCLES 2016 [Turn over

(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]

240

6

9608/33/M/J/16© UCLES 2016

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 system 1Guest operating

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]

241

7

9608/33/M/J/16© UCLES 2016 [Turn over

(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]

242

8

9608/33/M/J/16© UCLES 2016

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.

serial

sequential

random

File organisation method

direct

sequential

File access method

[4]

243

9

9608/33/M/J/16© UCLES 2016 [Turn over

(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]

244

10

9608/33/M/J/16© UCLES 2016

5 (a) Complete the truth table for this NAND gate:

A

B

X

A B X

0 0

0 1

1 0

1 1

[1]

A SR flip-flop is constructed using two NAND gates.

S

Q

R

Q

(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]

245

11

9608/33/M/J/16© UCLES 2016 [Turn over

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]

246

12

9608/33/M/J/16© UCLES 2016

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]

247

13

9608/33/M/J/16© UCLES 2016 [Turn over

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.

InstructionExplanation

Op code Operand

LDD <address> Direct addressing. Load the contents of the given 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)

ADD <address> Add the contents of the given address to the contents of ACC

AND <address> Bitwise AND operation of the contents of ACC with the contents of <address>

CMP #n Compare the contents of ACC with the number n

JMP <address> Jump to the given address

JPE <address> Following a compare instruction, jump to <address> if the compare was True

JGT <address>Following a compare instruction, jump to <address> if the content of ACC is greater than the number used in the compare instruction

END End the program and return to the operating system

248

14

9608/33/M/J/16© UCLES 2016

(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

249

15

9608/33/M/J/16© UCLES 2016

(i) Dry run the assembly language code. Start at LOOP and finish when EXIT is reached.

BITREG COUNT VALUE ACCB00001010 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]

250

® IGCSE is the registered trademark of Cambridge International Examinations.

This document consists of 6 printed pages.

© UCLES 2016 [Turn over

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.

251

Page 2 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2016 9608 33

© Cambridge International Examinations 2016

Question Answer Marks

1 (a) Single line joining all four computers and file server One “terminator” at each end

1 1

(b)

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.

1

1

1

(c) (i) Collision 1

(ii) Both stop transmitting Each uses a random time Wait for time period Check for bus status Attempt to re-transmit

1 1 1 1 1

Max 3

(d) Star topology created A switch has a number of ports Each connects to a single device (using a dedicated cable) Switch provides direct transmission/path from device to device Collisions are no longer possible There are dedicated links from Computer A to Computer C AND from the Server to Computer D

1 1 1 1 1 1

Max 4

2 (a) Examples: Serial number Certificate Authority that issued certificate CA digital signature Name of company/organisation/individual/subject/owner owning Certificate ‘Subject’ public key Period during which Certificate is valid // some relevant date

A mark for

each correct

data item –

Max 3

(b) (i) Public The individual keeps their private key private // the public key can be known by others (the public)

1

1

(ii) Public 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

1

252

Page 3 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2016 9608 33

© Cambridge International Examinations 2016

(iii) Private ‘Only’ the CA’s public key will allow decryption of the Certificate // proving the certificate was issued by the CA

1

1

(c) (i) Digital signature 1

(ii) Alexa’s digital certificate (Includes) Alexa’s public key Used to hash message received // produce message digest Generated hash compared to digital signature

1 1 1 1

Max 2

(iii) Examples: Financial transaction Legal document Software distribution

1 1 1

Max 2

3 (a) (i) Examples: Create / delete virtual machine Existing hardware made available to guest OS // hardware emulation Ensures each virtual machine is protected from actions of another virtual machine

1 1 1

Max 2

(ii) Guest operating system: An operating system running in a virtual machine // Controls virtual hardware // OS is being emulated 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 software Guest OS is running under the Host OS software

1

1

1

Max 2

(b) (i) Examples: Trial/use alternative replacement operating system(s) … Test to identify possible problems Much easier to create VM with a new OS than create new computer system Trial/use alternative replacement web server software … 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 (which does not disrupt the web server service)

Two marks

for each use

Maximum two uses

Max 4

253

Page 4 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2016 9608 33

© Cambridge International Examinations 2016

(ii) Examples: Using virtual machine means execution of extra code // emulation of some hardware … Non-VM installation may not perform in the same way Execution speed slower than non-VM system Problems in judging actual response times at time of maximum traffic needs fastest possible speed Particular hardware may be difficult to emulate

1

1 1 1 1

1 Max 2

4 (a)

File organisation method File access method

serial

direct

sequential

sequential

random

1

2

1

(b) (i) Sequential As all customers get statement … // high hit rate Suitable for batch processing of the records // the records will be processed one after the other File organised using customer’s unique ID (as primary key field) // Serial As all customers get statement … // high hit rate Suitable for batch processing of the records // the records will be processed one after the other Order not important

1 1

1 1

1 1

1 1

Max 3

(ii) Random Real-time transaction processing Requires fastest access to data No need to search through records

1 1 1 1

Max 3

254

Page 5 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2016 9608 33

© Cambridge International Examinations 2016

(iii) Serial Each new record is appended Transactions are recorded in chronological order File re-organisation not required for each new record // no need for the records to be sorted

1 1 1

Max 3

5 (a)

A B X

0 0 1

0 1 1

1 0 1

1 1 0

1

(b) (i)

S R Q Q

1 0 0 1

1 1 0 1

0 1 1 0

1 1 1 0

0 0 1 1

1

1

1

1

(ii) S = 0 R = 0 Produces Q = 1 , Q =1 // Q and Q have same value But Q and Q should be complements of each other Becomes unstable

1

1 1 1

Max 3

(c) (i) Clock (pulse) 1

(ii) All four possibilities are valid The 1-1 combination changes output to logical complement Unstable state avoided Invalid state cannot occur // the flip-flop is stable

1 1 1 1

Max 1

(d) Memory // data storage Stores a single bit

1 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

255

Page 6 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2016 9608 33

© Cambridge International Examinations 2016

(b) Examples: Pressure … If intruder steps on sensor Infra-red … If beam cut by intruder Motion / ultrasonic… Detects any movement in an area Contact / magnetic … If door / window opened

1 – sensor 1 – justification Maximum 2 sensors

Max 4

(c) (i)

BITREG COUNT VALUE ACC

B00001010 0 1 B00001010

B00000000

1

2 2

B00001010

B00000010

0

1 1

2

4 4

B00001010

B00000000

4

8 8

B00001010

B00001000

1

2 2

8

Mark as follows: 1 mark for: COUNT column VALUE column First two values in ACC column Rest of ACC column

Max 4

(ii) #1 1

(iii) CMP #8 CMP #128

1

1

256

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

DC (NH/SG) 123568© UCLES 2016 [Turn over

*9

43

65

48

12

6*

COMPUTER SCIENCE 9608/42

Paper 4 Further Problem-solving and Programming Skills May/June 2016

PRE-RELEASE MATERIAL

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.

Cambridge International ExaminationsCambridge International Advanced Level

257

2

9608/42/PRE/M/J/16© UCLES 2016

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.

RemindersThe 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 ...................................................................................................

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

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

258

3

9608/42/PRE/M/J/16© UCLES 2016 [Turn over

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.

259

4

9608/42/PRE/M/J/16© UCLES 2016

Jackson Structured Programming (JSP)

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

X

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.

Draw the JSP data structure diagram.

Key focus: JSP data structure diagrams

Key focus: Using ‘sequence’ …

260

5

9608/42/PRE/M/J/16© UCLES 2016 [Turn over

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

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.

Draw the JSP data structure diagram.

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.

Key focus: Using ‘sequence’ …

Key focus: Using ‘iteration’ …

261

6

9608/42/PRE/M/J/16© UCLES 2016

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.

*

*

Ship

FileBody

ShipFile

FileHeader FileTrailer

ShipName ShipVoyage

1

2

3

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.

262

7

9608/42/PRE/M/J/16© UCLES 2016 [Turn over

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:

*Ship

ShipVoyage

FileBody

ShipFile

FileHeader FileTrailer

ShipName ShipBody

*

Task 6

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.

Key focus: A data structurediagram for output

263

8

9608/42/PRE/M/J/16© UCLES 2016

Logic Programming

Task 7

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.

For example, [X|Y] denotes a list with:

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 itemThe tail is always a listPredicates 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:

TRUE when X = []FALSE when X has one or more elements

Example:

isEmpty(Cities) would return FALSE.

Key focus:Lists

Key focus:The ‘⎜’ list operator

Key focus:Predicates with lists

264

9

9608/42/PRE/M/J/16© UCLES 2016 [Turn over

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?

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

265

10

9608/42/PRE/M/J/16© UCLES 2016

7.4.2

removeAndCompare([orange,banana],[ ],[orange,banana])

What is returned by this predicate?

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

266

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

DC (LM/SG) 124303© UCLES 2016 [Turn over

*6

25

05

51

90

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.

Cambridge International ExaminationsCambridge International Advanced Level

267

2

9608/42/M/J/16© UCLES 2016

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 5000Surname 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]

268

3

9608/42/M/J/16© UCLES 2016 [Turn over

(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

StartPtr INTEGER Index to array SurnameList. Points to the 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]

269

4

9608/42/M/J/16© UCLES 2016

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

270

5

9608/42/M/J/16© UCLES 2016 [Turn over

(i) Complete the trace table for the dry-run of the pseudocode for the procedureCALL X(1, 9).

MyListIndex 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]

271

6

9608/42/M/J/16© UCLES 2016

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]

272

7

9608/42/M/J/16© UCLES 2016 [Turn over

(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

HIRE_LIST

HIRE

CAR

No hires One or more hires

*

[5]

273

8

9608/42/M/J/16© UCLES 2016

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]

274

9

9608/42/M/J/16© UCLES 2016 [Turn over

(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]

275

10

9608/42/M/J/16© UCLES 2016

(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]

276

11

9608/42/M/J/16© UCLES 2016 [Turn over

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]

277

12

9608/42/M/J/16© UCLES 2016

(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]

278

13

9608/42/M/J/16© UCLES 2016 [Turn over

(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...53Second number...6Arithmetic 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]

279

14

9608/42/M/J/16© UCLES 2016

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.

WHITEWINS

BLACK moves

No movepossible

TURN

TURN

Winningmove

BLACKWINS

Stalemate

[4]

(b) The layout of the board at the start of the game is shown below:

1 2 3 4 5 6 7 8

1

2

3

4

5

6

7

8

y

x

280

15

9608/42/M/J/16© UCLES 2016 [Turn over

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]

281

16

9608/42/M/J/16© UCLES 2016

(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.

1 2 3 4 5 6 7 8

1

2

3

4

5

6

7

8

y

x

The program requires a procedure ValidMoves.

It needs three parameters:

• PieceColour – colour of the moving piece • xCurrent – current x position • yCurrent – current y position

The procedure will calculate all possible destination squares in the x direction only.

Example output for the circled black piece is:

Possible moves are:Moving LEFT3 42 4 REMOVE pieceMoving RIGHT5 46 47 4

Write program code for procedure ValidMoves with the following procedure header:

PROCEDURE ValidMoves(PieceColour : CHAR, xCurrent : INTEGER, yCurrent : INTEGER).

282

17

9608/42/M/J/16© UCLES 2016 [Turn over

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 .....................................................................................................

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

283

18

9608/42/M/J/16© UCLES 2016

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

284

19

9608/42/M/J/16© UCLES 2016

(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]

285

® IGCSE is the registered trademark of Cambridge International Examinations.

This document consists of 15 printed pages.

© UCLES 2016 [Turn over

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.

286

Q

1

Qu

P

es

(a)

(b)

(c)

Pag

tio

) (

(i

) (

(i

) (

ge

on

(i)

ii)

(i)

ii)

(i)

2

TY

(D

(D

EN

AcLi

Su

Pt

EN

AcTY

Su

Pt

EN

AcST

(D

(D

EN

Ac

(D

Ac

Ac

AcInd

Wu

Ac

6

Is

BO

YPE

DEC

DEC

NDT

cceink

urn

tr

NDR

cceYPE

urn

tr

NDT

cceTRU

DEC

DEC

NDS

cce

DEC

cce

cce

ccedex

u

cce

sFo

OOL

E L

CLA

CLA

TYP

eptked

nam

:

REC

eptE L

nam

:

TYP

eptUCT

CLA

CLA

STR

ept

CLA

ept

ept

ept x s

ept

oun

LEA

C

Lin

ARE

ARE

PE

t: dL

me

IN

COR

t: Lin

me

IN

PE

t: TUR

ARE

ARE

RU

AS

ARE

AS

(

wisep

wi

nd

AN

Cam

nk

E)

E)

is

:

NT

RD

nk

:

NT

/

RE

E)

E)

CT

S /

E)

S /

) i

thopara

th

+

mb

ked

S

P

t

S

EG

D

ked

S

EG

E

L

S

P

UR

/ O

S

/ O

nst

outato

qu

rel

brid

dLi

Sur

Ptr

:

STR

GER

dLi

STR

GER

END

Lin

Sur

Ptr

RE

OF

Sur

OF

tea

t loor c

ote

ev

dge

ist

rna

r :

RE

RIN

R

ist

RIN

R

DRE

nke

rna

r :

in

rna

in

ad

wecan

es

ant

e In

©

t

ame

: I

ECO

NG

t =

NG

ECO

edL

ame

: I

nste

ame

nste

of

er bn be

t d

nte

Ca

e

IN

OR

=

OR

Li

e

IN

ea

eL

ea

[]

boue ,

es

ern

amb

:

TE

D

RE

D

st

:

TE

d o

is

d o

und,

crip

M

nati

brid

ST

EGE

ECO

t

ST

EGE

of

st[

of

d :

ptio

Mar

ion

dge

TRI

ER

ORD

TRI

ER

:

[1:

:

..

on

k S

nal

e In

ING

D

ING

:50

.

Sch

A

nter

G

G

000

hem

Le

rnat

A

0]

me

eve

tion

An

:

e

el –

nal

nsw

L

– M

Ex

wer

Lin

May

xam

r

nke

y/J

mina

edL

Jun

atio

Li

ne

ons

st

20

s 20

t

16

016

6

6

SSyl

9

llab

960

bu

08

s P

1

1

1

1

1

1

1

1

1

1

1

1

1

1

Pa

4

pe

42

er

Mark

3

2

1

1

2

ks

287

Page 3 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2016 9608 42

© Cambridge International Examinations 2016

Question Answer Marks

(ii) Accept () instead of []

01 Current ← StartPtr

02 IF Current = 0

03 THEN

04 OUTPUT "Empty List" (or similar message)

(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

6

Accept = for assignment

2 (a) (i) A procedure which is defined in terms of itself // A procedure which makes a call to itself // A procedure that calls itself

1

(ii) 08 // 8 1

288

Page 4 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2016 9608 42

© Cambridge International Examinations 2016

Question Answer Marks

(b) (i) 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

2

3

4 13

5 16

6 27

7 0

8

Note: Final mark only if no additional entries in table Accept last row to show all final values

4

(ii) Any one from: 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

1

289

Page 5 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2016 9608 42

© Cambridge International Examinations 2016

Question Answer Marks

3 (a)

F_BODY F_TRAILER

HIRE-TRANS

Customer

dataHire data

CustomerIDCustomer

NameCar Reg Hire start

date

Number of

days hired

TRANS

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

7

290

Page 6 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2016 9608 42

© Cambridge International Examinations 2016

Question Answer Marks

(b)

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

5

291

Page 7 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2016 9608 42

© Cambridge International Examinations 2016

Question Answer Marks

4 (a) (i) a03, h07, a23

accept in any order, must be lower case

1

(ii) The car must pass (both) brake test and tyres test 1

(b) retestAllowed(ThisCar) 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.

3

(c) (i) a07 [p03]

must be []

must be lower case, but don’t penalise twice, so follow through from part(b)

2

(ii) [p05,m04] 1

(iii) [ ] 1

(d) [ ] 1

5 (a) (i)

Mark Description Expected result (Grade)

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

3

(ii) (The programmer is) concerned only with the input (i.e. the mark) to the function and monitoring the expected output (i.e. the grade) // can compare expected result and actual result

1

(b) Exception: 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

3

292

Page 8 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2016 9608 42

© Cambridge International Examinations 2016

Question Answer Marks

(c) 1 Open a non-existent file 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

Max 3

(d) (i) 09 // 9 1

(ii) 1 Line 11 catches exceptions (only) between lines 05 and 10 1 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

Max 3

6 (a)

Max 3 marks if extra states/transitions added.

4

293

Page 9 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2016 9608 42

© Cambridge International Examinations 2016

Question Answer Marks

(b) (i) Mark as follows: 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)

4

(ii) Mark as follows: 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

Max 5

(c) (i) Classes could be designed for :

• the board

• a piece Containment (Board contains Pieces) The pieces are instances/objects (of the Piece class)

Max 2

294

Page 10 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2016 9608 42

© Cambridge International Examinations 2016

Question Answer Marks

(ii) Accept any reasonable answer, for example: 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

Max 2

295

Page 11 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2016 9608 42

© Cambridge International Examinations 2016

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.

296

Page 12 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2016 9608 42

© Cambridge International Examinations 2016

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)

297

Page 13 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2016 9608 42

© Cambridge International Examinations 2016

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

298

Page 14 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2016 9608 42

© Cambridge International Examinations 2016

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;

299

Page 15 Mark Scheme Syllabus Paper

Cambridge International A Level – May/June 2016 9608 42

© Cambridge International Examinations 2016

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

300

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

DC (NF/AR) 116626/4© UCLES 2016 [Turn over

Cambridge International ExaminationsCambridge International Advanced Level

*2

15

53

96

65

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.

301

2

9608/31/O/N/16© UCLES 2016

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]

302

3

9608/31/O/N/16© UCLES 2016 [Turn over

(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]

303

4

9608/31/O/N/16© UCLES 2016

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 source code.

Lexical analysis

This stage could be ignored.

Syntax analysis

This stage checks the grammar of the program source code.

Code generation

This stage produces a tokenised version of the program source code.

Optimisation

[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]

304

5

9608/31/O/N/16© UCLES 2016 [Turn over

(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.

2

[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]

305

6

9608/31/O/N/16© UCLES 2016

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 flag

Page frame address Additional data

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]

306

7

9608/31/O/N/16© UCLES 2016 [Turn over

(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 flag

Page frame address Additional data

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 flag

Page frame address Additional data

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

[3]

307

8

9608/31/O/N/16© UCLES 2016

(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

YA

B

Input OutputX Y A B0 00 11 01 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]

308

9

9608/31/O/N/16© UCLES 2016 [Turn over

(b) (i) Write the Boolean expression corresponding to the following logic circuit:

X

A

B

C

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

(ii) Use Boolean algebra to simplify the expression that you gave in part (b)(i).

Show your working.

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

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

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

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

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

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

309

10

9608/31/O/N/16© UCLES 2016

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]

310

11

9608/31/O/N/16© UCLES 2016

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]

311

® IGCSE is the registered trademark of Cambridge International Examinations.

This document consists of 7 printed pages.

© UCLES 2016 [Turn over

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.

312

Page 2 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 31

© UCLES 2016

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]

313

Page 3 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 31

© UCLES 2016

2 (a) Statement Compilation stage

1 mark for each correct

line

This stage removes any comments in the program code

Lexical analysis

This stage could be ignored

Syntax analysis

This stage checks the grammar of the program code

Code generation

This stage produces a tokenised version of the program code

Optimisation

[4] (b) (i) A B + [1]

C D – * [1] (ii) A – [1]

B / 4 * [1] C D – / [1]

(c) (i)

1 mark

per ring

4 3

1 1 5 5 2

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]

314

Page 4 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 31

© UCLES 2016

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 Flag

Page frame address

Additional data

4 1 542 12:07:34:49 [1 +1 + 1]

(iii) Number of times the page has been accessed [1] (iv)

Page Presence Flag

Page frame address

Additional data

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]

315

Page 5 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 31

© UCLES 2016

4 (a) (i)

[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]

Input Output

1 mark for each correct column

(A and B)

X Y A B 0 0 0 0

0 1 0 1

1 0 0 1

1 1 1 0

316

Page 6 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 31

© UCLES 2016

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]

317

Page 7 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 31

© UCLES 2016

6 (a) Description Term

Malware which attaches itself to another program. VIRUS [1]

Malware designed to redirect the web browser to a fake website. PHARMING [1]

Email that encourages the receiver to access a website and give their banking details.

PHISHING [1]

(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]

318

This document consists of 12 printed pages.

DC (ST/JG) 116627/3© UCLES 2016 [Turn over

Cambridge International ExaminationsCambridge International Advanced Level

*7

09

88

87

86

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.

319

2

9608/32/O/N/16© UCLES 2016

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]

320

3

9608/32/O/N/16© UCLES 2016 [Turn over

(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]

321

4

9608/32/O/N/16© UCLES 2016

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.

This stage can improve the time taken to execute the statement: x = y + 0

Statement

This stage produces object code.

This stage makes use of tree data structures.

This stage enters symbols in the symbol table.

Lexical analysis

Compilation stage

Syntax analysis

Code generation

Optimisation

[4]

(b) Write the Reverse Polish Notation (RPN) for the following expression.

P + Q – R / S

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

322

5

9608/32/O/N/16© UCLES 2016 [Turn over

(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]

323

6

9608/32/O/N/16© UCLES 2016

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 flag

Page frame address Additional data

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]

324

7

9608/32/O/N/16© UCLES 2016 [Turn over

(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 flag

Page frame address Additional data

6 …………. ………..…… …………………….……

[3]

325

8

9608/32/O/N/16© UCLES 2016

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]

326

9

9608/32/O/N/16© UCLES 2016 [Turn over

(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]

327

10

9608/32/O/N/16© UCLES 2016

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.

X A

Y BHALF ADDER

X A

Y BHALF ADDER

PJ

K

Q

R

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]

328

11

9608/32/O/N/16© UCLES 2016 [Turn over

(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

C

X

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

(ii) Use Boolean algebra to simplify the expression given in part (b)(i).

Show your working.

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

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

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

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

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

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

329

12

9608/32/O/N/16© UCLES 2016

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.

ServerComputerA

ComputerB

ComputerC

ComputerD

Switch

[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.

330

® IGCSE is the registered trademark of Cambridge International Examinations.

This document consists of 7 printed pages.

© UCLES 2016 [Turn over

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.

331

Page 2 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 32

© UCLES 2016

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 0 0 0 0 0 0 0

0 1 1 1 1 1 1 1 [1][1]

332

Page 3 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 32

© UCLES 2016

2 (a) Statement Compilation stage

1 mark for

each correct

line

This stage can improve the time taken to execute the statement: x = y + 0

Lexical analysis

This stage produces object code.

Syntax analysis

This stage makes use of tree data structures.

Code generation

This stage enters symbols in the symbol table.

Optimisation

[4] (b) P Q + [1]

R S / – [1] (c) (i)

2

1 mark

per ring

3 3 5

2 1 1 1 1 6

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 ]

333

Page 4 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 32

© UCLES 2016

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 Flag

Page frame address Additional data

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]

334

Page 5 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 32

© UCLES 2016

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]

335

Page 6 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 32

© UCLES 2016

5 (a) (i)

Input Working space

Output

1 mark each column

If zero marks then 6 or 7 pairs correct – 1 mark

P Q R J K 0 0 0 0 0

0 0 1 0 1

0 1 0 0 1

0 1 1 1 0

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]

336

Page 7 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 32

© UCLES 2016

6 (a)

4 × Computer to

Switch [1]

Server to Switch

[1]

(b)

Statement True False

All packets must be routed via the server. [1]

Computer B can read a copy of the packet sent from the Server to Computer A. [1]

No collisions are possible. [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]

Server Computer B

Computer D

Computer A

Computer C Switch

337

This document consists of 12 printed pages.

DC (ST) 115878/4© UCLES 2016 [Turn over

Cambridge International ExaminationsCambridge International Advanced Level

*2

85

77

96

95

0*

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 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.

338

2

9608/41/PRE/O/N/16© UCLES 2016

Teachers and candidates should read this material prior to the November 2016 examination for 9608 Paper 4.

RemindersThe 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.

339

3

9608/41/PRE/O/N/16© UCLES 2016 [Turn over

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 ENDFORENDPROCEDURE

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 taskExplore 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?

340

4

9608/41/PRE/O/N/16© UCLES 2016

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

ExplanationOp 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

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

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

341

5

9608/41/PRE/O/N/16© UCLES 2016 [Turn over

Notes:

# denotes immediate addressingB 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.

342

6

9608/41/PRE/O/N/16© UCLES 2016

TASK 2.1

X ← A + BEND

Label

Instruction

CommentOp code Operand

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

343

7

9608/41/PRE/O/N/16© UCLES 2016 [Turn over

TASK 2.2

IF X = A THEN OUTPUT CHR(X) // statements for THEN part ELSE A ← A + 1 // statements for ELSE partENDIFEND

Label

Instruction

CommentOp code Operand

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.

344

8

9608/41/PRE/O/N/16© UCLES 2016

TASK 2.3

REPEAT OUTPUT CHR(X) X ← X - 1UNTIL X = AEND

Label

Instruction

CommentOp code Operand

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

345

9

9608/41/PRE/O/N/16© UCLES 2016 [Turn over

TASK 2.4

FOR COUNT ← 1 TO 4 OUTPUT CHARS[COUNT]ENDFOREND

Label

Instruction

CommentOp code Operand

// 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'

346

10

9608/41/PRE/O/N/16© UCLES 2016

TASK 2.5

WHILE X <> B OUTPUT CHARS[B] B ← B + 1ENDWHILE END

LabelInstruction

CommentOp code Operand

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'

347

11

9608/41/PRE/O/N/16© UCLES 2016 [Turn over

TASK 2.6

Output a string using indirect addressing.

Address

Instruction

CommentOp code Operand

LOOP: // use indirect addressing to load contents of 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

348

12

9608/41/PRE/O/N/16© UCLES 2016

TASK 2.7

Programmers use bitwise operations (AND, OR, XOR) to set or examine specific bits.

Example:

Label

Instruction

CommentOp code Operand

LOOP: LDD X // load content of X into ACC

AND MASK // bitwise AND operation on content of ACC and 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.

349

This document consists of 16 printed pages.

DC (ST/SW) 115877/3© UCLES 2016 [Turn over

Cambridge International ExaminationsCambridge International Advanced Level

*8

11

83

78

60

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.

350

2

9608/41/O/N/16© UCLES 2016

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

351

3

9608/41/O/N/16© UCLES 2016 [Turn over

(a) Complete the state-transition diagram.

start

Door openno code set

Door closed

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

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

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

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

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

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

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

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

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

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

[7]

352

4

9608/41/O/N/16© UCLES 2016

(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.

SafetyDepositBoxCode : 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]

353

5

9608/41/O/N/16© UCLES 2016 [Turn over

(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]

354

6

9608/41/O/N/16© UCLES 2016

(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

Is Chars = 'R'?Yes Yes

NoNo

No

No

No

No

Yes Yes

Yes

Is State ="Open-CodeSet"? CALL Reset()

CALL SetState("Open-NoCode")

Is Chars = Code? Is State ="Locked"?

Is Chars = ""and State =

"Open-CodeSet"?

CALL SetNewCode(Chars)

OUTPUT "Error –code formatincorrect"

ENDMETHOD

OUTPUT "Error –does not match

set code"

No

YesIs Chars a valid4-digit code?

No

YesIs State ="Open-NoCode"?

CALL SetState("Open-CodeSet")

CALL SetState("Closed")

CALL SetState("Open-CodeSet")

YesIs State ="Closed"?

CALL SetState("Locked")

355

7

9608/41/O/N/16© UCLES 2016 [Turn over

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

.....................................................................................................................................[12]

356

8

9608/41/O/N/16© UCLES 2016

(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]

357

9

9608/41/O/N/16© UCLES 2016 [Turn over

(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:

SafetyDepositBoxPRIVATE

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]

358

10

9608/41/O/N/16© UCLES 2016

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]

359

11

9608/41/O/N/16© UCLES 2016 [Turn over

Question 2 continues on page 12.

360

12

9608/41/O/N/16© UCLES 2016

(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

0102030405060708091011

def BinarySearch(List, Low, High, SearchItem): Index = -1 while (Index == -1) AND (Low <= High): Middle = (High + Low) // 2 if List[Middle] == SearchItem: Index = Middle elif List[Middle] < SearchItem: Low = Middle + 1 else: High = Middle - 1 return(Middle)

B) Pascal/Delphi

01

0203040506070809101112131415

FUNCTION BinarySearch(VAR List : ARRAY OF INTEGER; Low, High, SearchItem : INTEGER) : INTEGER;VAR Index, Middle : INTEGER;BEGIN Index := -1; WHILE (Index = -1) & (Low <= High) DO BEGIN Middle := (High + Low) DIV 2; IF List[Middle] = SearchItem THEN Index := Middle ELSE IF List[Middle] < SearchItem THEN Low := Middle + 1 ELSE High := Middle - 1; END; Result := Middle;END;

C) Visual Basic

01

0203040506070809101112131415

Function BinarySearch(ByRef List() As Integer, ByVal Low As Integer, ByVal High As Integer, ByVal SearchItem As Integer) As Integer Dim Index, Middle As Integer Index = -1 Do While (Index = -1) & (Low <= High) Middle = (High + Low) \ 2 If List(Middle) = SearchItem Then Index = Middle ElseIf List(Middle) < SearchItem Then Low = Middle + 1 Else High = Middle - 1 End If Loop BinarySearch = MiddleEnd Function

361

13

9608/41/O/N/16© UCLES 2016 [Turn over

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]

362

14

9608/41/O/N/16© UCLES 2016

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

ExplanationOp 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.

LDX <address>Indexed addressing. Form the address from <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).

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.

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.

OUT Output to the screen the character whose ASCII value is stored in 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.

363

15

9608/41/O/N/16© UCLES 2016 [Turn over

Label Op code Operand Comment

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]

364

16

9608/41/O/N/16© UCLES 2016

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.

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]

365

® IGCSE is the registered trademark of Cambridge International Examinations.

This document consists of 12 printed pages.

© UCLES 2016 [Turn over

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.

366

Page 2 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 41

© UCLES 2016

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;

367

Page 3 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 41

© UCLES 2016

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;

368

Page 4 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 41

© UCLES 2016

VB: VB:Public Sub SetState(ByVal NewState As String) State = NewState Console.WriteLine(State) End Sub

Private _State As String Public Property State() As String Get 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

369

Page 5 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 41

© UCLES 2016

(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

370

Page 6 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 41

© UCLES 2016

(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")

371

Page 7 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 41

© UCLES 2016

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;

372

Page 8 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 41

© UCLES 2016

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;

373

Page 9 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 41

© UCLES 2016

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) & (Low <= High):

WHILE (Index = -1) AND (Low <= High) DO

DO WHILE (Index = -1) AND (Low <= High)

[1]

374

Page 10 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 41

© UCLES 2016

(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

375

Page 11 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 41

© UCLES 2016

3 START: LDR #0 // initialise index register to zero [1]

LDM #0 // initialise COUNT to zero [1]

STO COUNT

LOOP1: LDX NAME // load character from indexed address NAME [1]

OUT // output character to screen [1]

INC IX // increment index register [1]

LDD COUNT // increment COUNT starts here [1] INC ACC

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

LOOP2: LDX NAME // load character from indexed address NAME [1]

OUT // output character to screen DEC IX // decrement index register [1]

LDD COUNT // increment COUNT starts here [1] INC ACC //

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]

376

Page 12 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 41

© UCLES 2016

4 Acceptance testing Integration testing

Who The end user // user of the software

The programmer / in-house testers [1] + [1]

When When the software is finished/ when it is installed

When the separate modules have been written and tested

[1] + [1]

Purpose To ensure the software is what the customer ordered // to check that the software meets the user requirements

To ensure the modules work together as expected

[1] + [1]

377

This document consists of 12 printed pages.

DC (ST) 128071© UCLES 2016 [Turn over

Cambridge International ExaminationsCambridge International Advanced Level

*4

19

38

61

87

5*

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 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.

378

2

9608/42/PRE/O/N/16© UCLES 2016

Teachers and candidates should read this material prior to the November 2016 examination for 9608 Paper 4.

RemindersThe 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.

379

3

9608/42/PRE/O/N/16© UCLES 2016 [Turn over

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 ENDFORENDPROCEDURE

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 taskExplore 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?

380

4

9608/42/PRE/O/N/16© UCLES 2016

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

ExplanationOp 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

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

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

381

5

9608/42/PRE/O/N/16© UCLES 2016 [Turn over

Notes:

# denotes immediate addressingB 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.

382

6

9608/42/PRE/O/N/16© UCLES 2016

TASK 2.1

X ← A + BEND

Label

Instruction

CommentOp code Operand

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

383

7

9608/42/PRE/O/N/16© UCLES 2016 [Turn over

TASK 2.2

IF X = A THEN OUTPUT CHR(X) // statements for THEN part ELSE A ← A + 1 // statements for ELSE partENDIFEND

Label

Instruction

CommentOp code Operand

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.

384

8

9608/42/PRE/O/N/16© UCLES 2016

TASK 2.3

REPEAT OUTPUT CHR(X) X ← X - 1UNTIL X = AEND

Label

Instruction

CommentOp code Operand

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

385

9

9608/42/PRE/O/N/16© UCLES 2016 [Turn over

TASK 2.4

FOR COUNT ← 1 TO 4 OUTPUT CHARS[COUNT]ENDFOREND

Label

Instruction

CommentOp code Operand

// 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'

386

10

9608/42/PRE/O/N/16© UCLES 2016

TASK 2.5

WHILE X <> B OUTPUT CHARS[B] B ← B + 1ENDWHILE END

LabelInstruction

CommentOp code Operand

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'

387

11

9608/42/PRE/O/N/16© UCLES 2016 [Turn over

TASK 2.6

Output a string using indirect addressing.

Address

Instruction

CommentOp code Operand

LOOP: // use indirect addressing to load contents of 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

388

12

9608/42/PRE/O/N/16© UCLES 2016

TASK 2.7

Programmers use bitwise operations (AND, OR, XOR) to set or examine specific bits.

Example:

Label

Instruction

CommentOp code Operand

LOOP: LDD X // load content of X into ACC

AND MASK // bitwise AND operation on content of ACC and 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.

389

This document consists of 17 printed pages and 3 blank pages.

DC (LEG/SW) 115870/4© UCLES 2016 [Turn over

Cambridge International ExaminationsCambridge International Advanced Level

*4

53

07

73

20

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.

390

2

9608/42/O/N/16© UCLES 2016

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)

Coinreturntray

Ticket dispenser

Coin Slot

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.

391

3

9608/42/O/N/16© UCLES 2016 [Turn over

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.

startCoin inserted

Coins returned

Cancelled

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

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

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

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

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

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

[7]

392

4

9608/42/O/N/16© UCLES 2016

(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.

TicketMachineAmount : INTEGER // total value of coins inserted in centsState : 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 stateStateChange() // insert coin or press button, // then take appropriate actionCoinInserted() // parameter is a string // change parameter to integer // and add coin value to AmountReturnCoins() // output Amount, then set Amount to zeroPrintTicket() // print ticket, then set Amount to zero

Write program code for the following methods.

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

(i) Create()

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

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

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

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

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

(ii) SetState()

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

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

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

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

393

5

9608/42/O/N/16© UCLES 2016 [Turn over

(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]

394

6

9608/42/O/N/16© UCLES 2016

(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

Is NewInput = 'C'?Yes Yes

No

No

No

No

No

Yes Yes

Yes

Is State ="Counting"? CALL SetState("Cancelled")

CALL ReturnCoins()

Is NewInput = 'A'? Is Amount = 0? OUTPUT "Nocoins inserted"

CALL SetState("Accepted") CALL PrintTicket()

Is NewInputa validcoin?

CALL CoinInserted(NewInput)

CALL SetState("Counting") CALL SetState("Idle")

OUTPUT "Error –not a valid

coin"

ENDMETHOD

395

7

9608/42/O/N/16© UCLES 2016 [Turn over

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

.....................................................................................................................................[12]

396

8

9608/42/O/N/16© UCLES 2016

(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]

397

9

9608/42/O/N/16© UCLES 2016 [Turn over

(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.

TicketMachinePRIVATE

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]

398

10

9608/42/O/N/16© UCLES 2016

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.

399

11

9608/42/O/N/16© UCLES 2016 [Turn over

(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]

400

12

9608/42/O/N/16© UCLES 2016

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

ExplanationOp 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.

LDX <address>Indexed addressing. Form the address from <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.

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>.

OUT Output to the screen the character whose ASCII value is 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.

401

13

9608/42/O/N/16© UCLES 2016 [Turn over

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.

Label Op code Operand Comment

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]

402

14

9608/42/O/N/16© UCLES 2016

Question 4 begins on page 15.

403

15

9608/42/O/N/16© UCLES 2016 [Turn over

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]

404

16

9608/42/O/N/16© UCLES 2016

(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

01020304050607080910

def BubbleSort(SList, Max): NoMoreSwaps = False while NoMoreSwaps == False: NoMoreSwaps = True for i in (Max - 1): if SList[i] > SList[i + 1]: NoMoreSwaps = True Temp = SList[i] SList[i] = SList[i + 1] SList[i + 1] = Temp

B) Pascal/Delphi

01020304050607080910111213141516

PROCEDURE BubbleSort(VAR SList : ARRAY OF INTEGER; Max : INTEGER);VAR NoMoreSwaps : BOOLEAN; i, Temp : INTEGER;BEGIN REPEAT NoMoreSwaps := TRUE; FOR i := 1 TO (Max – 1) IF SList[i] > SList[i + 1] THEN BEGIN NoMoreSwaps := TRUE; Temp := SList[i]; SList[i] := SList[i + 1]; SList[i + 1] := Temp; END; UNTIL NoMoreSwaps;END;

C) Visual Basic

0102030405060708091011121314

Sub BubbleSort(ByRef SList() As Integer, ByVal Max As Integer) Dim NoMoreSwaps As Boolean, i, Temp As Integer Do NoMoreSwaps = True For i : 0 To (Max – 1) If SList(i) > SList(i + 1) Then NoMoreSwaps = True Temp = SList(i) SList(i) = SList(i + 1) SList(i + 1) = Temp End If Next Loop Until (NoMoreSwaps = True)End Sub

405

17

9608/42/O/N/16© UCLES 2016

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]

406

® IGCSE is the registered trademark of Cambridge International Examinations.

This document consists of 13 printed pages.

© UCLES 2016 [Turn over

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.

407

Page 2 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 42

© UCLES 2016

1 (a) [7]

1 mark for each label

408

Page 3 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 42

© UCLES 2016

(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: Public Sub New() Amount = 0 State = "Idle" End Sub

VB: Public Sub Create() Amount = 0 state = “Idle” 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;

409

Page 4 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 42

© UCLES 2016

VB: Public Sub SetState(NewState As String) Me.State = NewState Console.WriteLine(Me.State) End Sub

VB: Private _State As String Public Property State() As String Get 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

410

Page 5 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 42

© UCLES 2016

(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

411

Page 6 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 42

© UCLES 2016

(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

412

Page 7 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 42

© UCLES 2016

(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

413

Page 8 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 42

© UCLES 2016

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

414

Page 9 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 42

© UCLES 2016

(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

415

Page 10 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 42

© UCLES 2016

(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 / programmers

(potential) (end) user(s)/client(s)

When Near the end of development // program is nearly fully-usable // after integration and before beta

Before general release of software // passed Alpha testing

Purpose To find errors not found in earlier testing // ensure ready for beta testing

For constructive comments/ feedback // to test in real-life 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

416

Page 11 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 42

© UCLES 2016

(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

LOOP: LDX WORD // load next character from indexed address WORD 1

OR MASK2 // make lower case using MASK2 1

OUT // output character to screen

LDD COUNT // increment COUNT

1 INC ACC //

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]

417

Page 12 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 42

© UCLES 2016

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-1) DO

For i = 0 To (Max – 1)

[1]

(b) (i) Python: compiled/interpreted [1]

VB.NET: compiled Pascal:compiled/interpreted Delphi: compiled/interpreted

418

Page 13 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 42

© UCLES 2016

(ii) 1 mark for naming error, 1 mark for line number and correction

A Logic error B Logic error C Logic error [1]

7 NoMoreSwaps = False

10 NoMoreSwaps := FALSE;

7 NoMoreSwaps = False

[1]

(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

419

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

DC (ST/SW) 158024/4© UCLES 2017 [Turn over

Cambridge International ExaminationsCambridge International Advanced Subsidiary and Advanced Level

*0474701175*

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.

420

2

9608/32/M/J/17© UCLES 2017

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

421

3

9608/32/M/J/17© UCLES 2017 [Turn over

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.

Variable Memory Address Contents

. . .

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]

422

4

9608/32/M/J/17© UCLES 2017

(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]

423

5

9608/32/M/J/17© UCLES 2017 [Turn over

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 site without their knowledge.

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

(ii) An attempt to acquire sensitive information, often for malicious reasons, by trying to deceive the user through the contents of an email.

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

(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]

424

6

9608/32/M/J/17© UCLES 2017

(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:

Q

R

S

P

(a) Write the Boolean algebraic expression corresponding to this logic circuit:

S = ........................................................................................................................................[4]

425

7

9608/32/M/J/17© UCLES 2017 [Turn over

(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

R0

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]

426

8

9608/32/M/J/17© UCLES 2017

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 for the current month.

Each time a customer submits their 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.

427

9

9608/32/M/J/17© UCLES 2017 [Turn over

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]

428

10

9608/32/M/J/17© UCLES 2017

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]

429

11

9608/32/M/J/17© UCLES 2017 [Turn over

(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]

430

12

9608/32/M/J/17© UCLES 2017

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

431

13

9608/32/M/J/17© UCLES 2017 [Turn over

(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]

432

14

9608/32/M/J/17© UCLES 2017

(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

Return to task 6. Enable interrupts

2. Save current task

3. Identify source of interrupt

4. Jump to Interrupt Service Routine

5. Restore task

(i) State the purpose of step 3.

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

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

(ii) Explain what happens at step 4.

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

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

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

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

433

15

9608/32/M/J/17© UCLES 2017

BLANK PAGE

434

16

9608/32/M/J/17© UCLES 2017

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.

BLANK PAGE

435

® IGCSE is a registered trademark.

This document consists of 7 printed pages.

© UCLES 2017 [Turn over

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.

436

9608/32 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 2 of 7

Question Answer Marks

1(a)(i) DECLARE NewFriend : MyContactDetail 1

1(a)(ii) NewFriend.HouseNumber ← 129 1

1(b) Declaration of Name, Area, HouseNumber 1Inclusion of three correct values for Area 1Inclusion of correct range for HouseNumber 1 For example: TYPE MyContactDetail

DECLARE Name : STRING DECLARE Area : (uptown, downtown, midtown) 1DECLARE HouseNumber : 1..499 1 & 1

ENDTYPE

3

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

437

9608/32 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 3 of 7

Question Answer Marks

2(a)(i) Pharming 1

2(a)(ii) Phishing 1

2(a)(iii) A standalone/independent piece of malicious software 1that can replicate/duplicate itself 1

2

2(b) No up-to-date anti-virus (or equivalent) software (used) / Regular virus scans not 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

2(c)(i) (Certificate) serial number 1Certificate Authority (that issued certificate) 1Valid date(s) // Date of expiry 1Subject name (name of user/owner, computer, network device) 1Subject public key 1Version (Number) 1Hashing algorithm (data or signature) 1

max 3

3

2(c)(ii) CA uses hashing algorithm .. 1To generate a message digest from the particular certificate 1Message digest is encrypted with CA’s private key 1

3

2(c)(iii) Need to know that the certificate is genuine (and has not been altered) // Authenticate or verify it (came from the CA)

1

438

9608/32 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 4 of 7

Question Answer Marks

3(a) S = ( P + ( RQ + ) ) . R P 1( RQ + ) 1(P +( RQ + ) ) 1. R (must be outside final brackets) 1 Or P 1( RQ + ) 1P +( RQ + ) 1( ..). R 1

4

3(b)

P Q R Working space S

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

2

3(c)(i)

PQ

00 01 11 10

R 0 0 0 0 0

1 1 1 0 0

1

3(c)(ii)

PQ

00 01 11 10

R 0 0 0 0 0

1 1 1 0 0

1

3(c)(iii) S = P . R 1

439

9608/32 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 5 of 7

Question Answer Marks

3(d) S = (P + ( RQ + ) ) . R S = (P + ( Q . R ) ) . R // P .R + ( RQ + ) . R 1S = (P . R ) + ( Q . R . R ) 1S= P . R + Q . 0 ) S= P . R + 0 ) 1S= P . R

3

Question Answer Marks

4(a)

File organisation method

File access 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

4(b)(i) File A: Serial 1Meter readings are submitted over time // added to the end of file 1Stored chronologically 1

3

4(b)(ii) File B: Sequential 1Any two points from: Each customer has a unique account number 1 Sorted on Account number 1High hit rate // Suitable for batch processing monthly statements 1

3

4(b)(iii) File C: Random 1Login without waiting // Random organisation allows fastest direct access to required record 1Low hit rate // Suitable for access to individual records 1

3

440

9608/32 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 6 of 7

Question Answer Marks

5(a)

Option 1 Option 2

Application Layer Application Layer

Transport Transport (Layer) 1

Internet Network (Layer) 1

Network Interface (Data) Link (Layer) 1

3

5(b)(i) Peer-to-peer 1

5(b)(ii) File sharing 1

5(b)(iii) Any four points from the following: • 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.

Max 4

5(c) Any two protocols from: HTTP/HTTPS 1Used for transfer of web pages from server to client 1FTP 1Used for interactive file transfer 1SMTP 1Used for sending email messages 1POP3 1Used for incoming email messages 1

Max 4

441

9608/32 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 7 of 7

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 conditions in the building if sensors triggered

1

6(a)(iii) Any two sensors from: Sound / acoustic Pressure Infra-red / motion /proximity Temperature / Thermal Light Smoke Tilt

Max 2

6(b)(i) 01 ForEver ← FALSE //TRUE 102 REPEAT 03 FOR FloorCounter ← 1 TO NoOfFloors 04 FOR SensorCounter ← 1 TO NumberOfSensors 105 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

3

6(b)(ii) FOR Counter ← 1 TO 999999 (any “large” number) ENDFOR

1

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 1On the correct monitor 1

2

442

This document consists of 12 printed pages.

DC (ST/SW) 144372/1© UCLES 2017 [Turn over

*5949332213*

COMPUTER SCIENCE 9608/42

Paper 4 Further Problem-solving and Programming Skills May/June 2017

PRE-RELEASE MATERIAL

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.

Cambridge International ExaminationsCambridge International Advanced Subsidiary and Advanced Level

443

2

9608/42/PRE/M/J/17© UCLES 2017

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)PythonPascal / 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.

444

3

9608/42/PRE/M/J/17© UCLES 2017 [Turn over

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• the topic

TASK 1.1

The relationship between Test and Question is shown in the following containment (aggregation) class diagram.

– TestID : String– Questions [1 : 10] : Question– NumberOfQuestions : Integer– MaxMarks : Integer– Level : Char– DateSet : Date

+ DesignTest()+ PrintTest()+ PrintAnswers()

1 1..*

Test– QuestionID : String– QuestionText : String– Answer : String– Marks : Integer– Topic : String

+ SetQuestion()+ GetQuestion() : String+ GetMarks() : Integer+ GetTopic() : String+ GetAnswer() : String

Question

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.

Key focus: Object-oriented programming

445

4

9608/42/PRE/M/J/17© UCLES 2017

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

ExplanationOp 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.

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.

446

5

9608/42/PRE/M/J/17© UCLES 2017 [Turn over

Notes:

# denotes immediate addressingB 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

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.

Key focus: Low-level programming

447

6

9608/42/PRE/M/J/17© UCLES 2017

TASK 2.1

X A + BEND

Label

Instruction

CommentOp code

Operand

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

448

7

9608/42/PRE/M/J/17© UCLES 2017 [Turn over

TASK 2.2

IF X = A THEN OUTPUT CHR(X) // statements for THEN part ELSE A A + 1 // statements for ELSE partENDIFEND

Label

Instruction

CommentOp code

Operand

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.

449

8

9608/42/PRE/M/J/17© UCLES 2017

TASK 2.3

REPEAT OUTPUT CHR(X) X X - 1UNTIL X = AEND

Label

Instruction

CommentOp code

Operand

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

450

9

9608/42/PRE/M/J/17© UCLES 2017 [Turn over

TASK 2.4

FOR COUNT 1 TO 4 OUTPUT CHARS[COUNT]ENDFOREND

Label

Instruction

CommentOp code

Operand

// 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'

451

10

9608/42/PRE/M/J/17© UCLES 2017

TASK 2.5

WHILE X <> B OUTPUT CHARS[B] B B + 1ENDWHILEEND

Label

Instruction

CommentOp code

Operand

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'

452

11

9608/42/PRE/M/J/17© UCLES 2017 [Turn over

TASK 2.6

Output a string using indirect addressing.

Address

Instruction

CommentOp code

Operand

LOOP: // use indirect addressing to load contents of 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

453

12

9608/42/PRE/M/J/17© UCLES 2017

TASK 2.7

Programmers use bitwise operations (AND, OR, XOR) to set or examine specific bits.

Example:

Label

Instruction

CommentOp code

Operand

START: LDD X // load content of X into ACC

AND MASK // bitwise AND operation on content of ACC and 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.

454

*6366267420*

This document consists of 17 printed pages and 3 blank pages.

DC (CW/SW) 129963/3© UCLES 2017 [Turn over

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.

Cambridge International ExaminationsCambridge International Advanced Subsidiary and Advanced Level

455

2

9608/42/M/J/17© UCLES 2017

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).

InstructionExplanation

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

456

3

9608/42/M/J/17© UCLES 2017 [Turn over

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.

Label Op code Operand Comment

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.

Label Op code Operand Comment

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]

457

4

9608/42/M/J/17© UCLES 2017

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

Dublin

RootPointer

BerlinØ

Ø

Ø

Ø

Ø Ø

Copenhagen

London

Paris

Madrid

Ø

Another data item to be added is Athens.

Make the required changes to the diagram when this data item is added. [2]

458

5

9608/42/M/J/17© UCLES 2017 [Turn over

(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]

459

6

9608/42/M/J/17© UCLES 2017

(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

Node RECORD Data structure to store node data and associated 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.

CreateTree() Procedure initialises the root pointer and free pointer and links all nodes together into the free list.

AddToTree() Procedure to add a new data item in the correct position in the binary tree.

FindInsertionPoint()

Procedure that finds the node where a new node is to be added.Procedure takes the parameter NewDataItem and returns two parameters:• 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”).

460

7

9608/42/M/J/17© UCLES 2017 [Turn over

(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]

461

8

9608/42/M/J/17© UCLES 2017

(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]

462

9

9608/42/M/J/17© UCLES 2017 [Turn over

(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]

463

10

9608/42/M/J/17© UCLES 2017

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

Grid ARRAY[0 : 9, 0 : 29] OF CHAR 2D array to represent the squares of the island

Constructor()instantiates an object of class IslandClass and initialises all squares to sand

HideTreasure()

generates a pair of random numbers used as the grid location of treasure and marks the square with 'T'

DigHole(Row, Column)

takes as parameters a valid grid location and marks the square with 'X' or 'O' as appropriate

GetSquare(Row, Column) CHAR

takes as parameter a valid grid location and returns the grid value for that square from the IslandClass object

464

11

9608/42/M/J/17© UCLES 2017 [Turn over

(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]

465

12

9608/42/M/J/17© UCLES 2017

(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]

466

13

9608/42/M/J/17© UCLES 2017 [Turn over

(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]

467

14

9608/42/M/J/17© UCLES 2017

(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]

468

15

9608/42/M/J/17© UCLES 2017 [Turn over

(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]

469

16

9608/42/M/J/17© UCLES 2017

(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]

470

17

9608/42/M/J/17© UCLES 2017

(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]

471

18

9608/42/M/J/17© UCLES 2017

BLANK PAGE

472

19

9608/42/M/J/17© UCLES 2017

BLANK PAGE

473

20

9608/42/M/J/17© UCLES 2017

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.

BLANK PAGE

474

® IGCSE is a registered trademark.

This document consists of 19 printed pages.

© UCLES 2017 [Turn over

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.

475

9608/42 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 2 of 19

Question Answer Marks

1(a)

Label Op code Operand Comment

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:

9

1(b)

Label Op code Operand Comment

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

6

476

9608/42 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 3 of 19

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 • node with ‘Athens’ linked to left pointer of Berlin (ignore null pointer) • null pointers in left and right pointers of Athens

2

2(c)(i) 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/∅

5

2(c)(ii) • –1 • It is not the number for any node.

2

477

9608/42 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 4 of 19

Question Answer Marks

2(d)(i) TYPE Node 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

7

478

9608/42 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 5 of 19

Question Answer Marks

2(d)(ii) PROCEDURE AddToTree(ByVal NewDataItem : STRING) // 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)

8

479

9608/42 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 6 of 19

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 • 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

5

480

9608/42 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 7 of 19

Question Answer Marks

3(a) 1 mark per bullet • 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;

3

481

9608/42 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 8 of 19

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

482

9608/42 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 9 of 19

Question Answer Marks

3(b) 1 mark per bullet to max 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;

5

483

9608/42 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 10 of 19

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

• 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

2

484

9608/42 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 11 of 19

Question Answer Marks

3(c)(ii) 1 mark per bullet • 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

4

485

9608/42 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 12 of 19

Question Answer Marks

3(d) 1 mark per bullet to 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;

Max 5

486

9608/42 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 13 of 19

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

487

9608/42 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 14 of 19

Question Answer Marks

3(e)(i) 1 mark per bullet • 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;

3

488

9608/42 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 15 of 19

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

489

9608/42 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 16 of 19

Question Answer Marks

3(e)(ii) 1 mark per bullet to 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

Max 5

490

9608/42 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 17 of 19

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;

491

9608/42 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 18 of 19

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

492

9608/42 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 19 of 19

Question Answer Marks

3(f)(ii) • IslandClass box and Square Box, with correct connection • One at IslandClass and one .. * at Square

Max 2

493