123
® IGCSE is a registered trademark. This document consists of 8 printed pages. © UCLES 2017 [Turn over Cambridge International Examinations Cambridge International Advanced Subsidiary and Advanced Level COMPUTER SCIENCE 9608/11 Paper 1 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.

Cambridge International Examinations Cambridge ...maxpapers.com/wp-content/uploads/2013/06/9608_s17_ms_all.pdf · 9608/11 Cambridge International AS/A Level – Mark Scheme PUBLISHED

Embed Size (px)

Citation preview

® IGCSE is a registered trademark.

This document consists of 8 printed pages.

© UCLES 2017 [Turn over

Cambridge International Examinations Cambridge International Advanced Subsidiary and Advanced Level

COMPUTER SCIENCE 9608/11 Paper 1 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.

9608/11 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 2 of 8

Question Answer Marks

1(a) Many-to-one 1

1(b)(i) A-NURSE(NurseID, FirstName, FamilyName, WardName) 1

1(b)(ii) • The primary key WardName in the A-WARD table 1• links to the foreign key WardName in the A-NURSE table. 1

2

1(c)(i) Many-to-many relationship 1

1(c)(ii) B-WARD-NURSE(WardName, NurseID) Both attributes (with no additions) 1Joint primary key correctly underlined 1

2

1(c)(iii)

B-WARD-NURSE

B-NURSE B-WARD

Correct relationship between B-NURSE and B-WARD-NURSE 1Correct relationship between B-WARD and B-WARD-NURSE 1

2

1(d)(i) SELECT NurseID, FamilyName 1FROM B-NURSE 1WHERE Specialism = 'THEATRE'; 1

3

1(d)(ii) UPDATE B-NURSE 1SET FamilyName = 'Chi' 1WHERE NurseID = '076'; 1

3

9608/11 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 3 of 8

Question Answer Marks

2(a)(i)

1 A laser beam and a rotating mirror are used to draw an image of the page on the photosensitive drum.

2 C // The image is converted on the drum into an electrostatic charge.

3 Electrostatic charge attracts toner.

4 The charged paper is rolled against the drum.

5 D // The oppositely-charged paper picks up the toner particles from the drum. After picking up the toner, the paper is discharged to stop it clinging to the drum.

6 A // The paper passes through a fuser, which heats up the paper. The toner melts and forms a permanent image on the paper.

7 B // The electrical charge is removed from the drum and the excess toner is collected.

C in the correct place 1DA, 1AB 1

3

2(a)(ii) Inkjet printer 1

2(b) Hard disk drive // HDD 1Solid state drive //SSD // flash memory 1One from: Hard disk Inexpensive per unit of storage 1Larger storage capacity than flash drive 1 Solid state storage No moving parts / noise 1 Robust 1Low latency // Fast read/write time 1

3

9608/11 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 4 of 8

Question Answer Marks

3(a) Sampling rate The number of samples taken per unit time // the number of times the amplitude is measured per unit time 1Increasing the sampling rate will increase the accuracy / precision of the digitised sound // Increasing the sampling rate will result in smaller quantisation errors. 1

2

3(b)(i) Pixel Smallest picture element which can be drawn 1Screen resolution The number of pixels which can be viewed horizontally and vertically on the screen // or by example - A typical screen resolution is 1680 pixels × 1080 pixels. 1

2

3(b)(ii) 8 1

3(b)(iii) Working: Max two from:

• Number of pixels is 2048 × 512 1

• One pixel will be stored as one byte 1

• Number of kilobytes = (2048 × 512) / 1024 1

Answer: One mark:

Number of kilobytes = 1024 KB 1

3

3(b)(iv) One from: • Confirmation that the file is a BMP 1• File size 1• Location/offset of image data within the file 1• Dimensions of the image in pixels // image resolution 1• Colour depth (bits per pixel) 1• Type of compression used, if any 1

1

9608/11 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 5 of 8

Question Answer Marks

4(a)(i) 500 1

4(a)(ii) 496 1

4(a)(iii) 502 1

4(a)(iv) 86 1

4(b) 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1

0 0 0 0 0 1 1 0 0 1 1 0 0 0 0 1

Both correct op codes 1Operand 0001 0001 1 Operand 0110 0001 1

3

4(c) 256 1

4(d)(i) 07 C2 07 1C2 1

2

4(d)(ii) LDI 63 LDI 163 1

2

9608/11 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 6 of 8

Question Answer Marks

5(a)(i) • Count the number of one bits in the first seven bit positions 1• Add a 0 or 1 to bit position 0, to make the count of one bits an odd number 1

2

5(a)(ii) A = 1 B = 1

1

5(a)(iii) Two from: • A parity bit is worked out for each column 1• The computer checks the parity of each bit position in parity byte // the computer

generates copy of the parity byte and compares 1• If incorrect parity then there is an error in the data received // No parity error

means no error in the data received 1• The position of the incorrect bit can be determined 1

2

5(b)(i) 2

5(b)(ii) Three from: • Consider each row in sequence 1• Identify any row with incorrect parity 1• Repeat the process for each column in sequence 1• Identify where a row and column with incorrect parity intersect 1

3

9608/11 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 7 of 8

Question Answer Marks

6(a)

One mark for each correct line from each left hand box to max three marks.

3

6(b)(i) File compression software 1

6(b)(ii) Backup software 1

6(b)(iii) Disk repair software 1

6(b)(iv) Anti-virus software 1

The user selects the Save command to save their spreadsheet file

The user selects the Print command to output their spreadsheet file

The user closes the Spreadsheet program

9608/11 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 8 of 8

Question Answer Marks

7(a) Two from:

• The user’s web browser is the client software 1• The requested web page has program code / script embedded within it 1• This code is interpreted by the web browser 1

2

7(b) Four from:

• The browser parses the URL to obtain the Domain Name 1• The browser software passes the Domain Name to the nearest Domain Name

Server (DNS) 1• The DNS stores a list of Domain Names and matching IP addresses 1• The DNS Name Resolver looks for the Domain Name in its database 1• If found the corresponding IP address is returned to the originator 1• If not found the request is forwarded to another higher level DNS 1• The original DNS adds the returned IP address to its cache 1• The original DNS returns the IP address to the originator 1• The browser uses the IP address to request the required web page from the web

server 1• The web server retrieves the page and delivers it to the originator 1• The browser software interprets the script and displays the web page 1

Max 4

7(c)(i) Message1, Message2 1x 1

2

7(c)(ii) 6 – 19 1

7(c)(iii) 11 1

7(c)(iv) Checks that the product code has not be left blank // presence check on product code

1

7(c)(v) Two checks from: One mark for check and one mark for description • Range check 1 Check the number entered is (say) between 1 and 100 1 • Format check 1 Checks the product code is a particular format // Checks the number has digit

characters only // by example 1 • Length check 1 The number of items has exactly five characters 1 • Existence check 1 To ensure the product code has been assigned 1

Max 4

® 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/12 Paper 1 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.

9608/12 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 2 of 7

Question Answer Marks

1(a) Many-to-many relationship 1

1(b)(i)

Both entities correctly labelled 1 Correct relationship between SHOP and SHOP-SUPPLIER 1 Correct relationship between SUPPLIER and SHOP-SUPPLIER 1

3

1(b)(ii)

Table Primary key Foreign keys(s) (if any)

Explanation

SHOP ShopID

None

SUPPLIER SupplierID

None

SHOP-SUPPLIER ShopID AND SupplierID

ShopID OR SupplierID (or both)

To create a link with the SHOP or SUPPLIER table.

• SHOP has primary key ShopID and SUPPLIER has primary key

SupplierID 1 • SHOP-SUPPLIER has primary key ShopID + SupplierID 1 • Both SHOP and SUPPLIER show foreign key as ‘None’ 1 • SHOP-SUPPLIER shows foreign key ShopID or SupplierID 1 • Explanation for SHOP-SUPPLIER foreign key describes ShopID or

SupplierID creating a link 1

5

1(b)(iii) Two from: • The database user will frequently want to search on contact name 1 • The contact name attribute has been indexed 1 • It allows for a fast/faster search using contact name 1

Max 2

1(c)(i) SELECT ShopID, Location 1 FROM SHOP 1 WHERE RetailSpecialism = 'GROCERY'; 1

3

1(c)(ii) INSERT INTO SHOP-SUPPLIER 1 (ShopID, SupplierID) 1 VALUES (8765, 'SUP89'); 1

3

9608/12 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 3 of 7

Question Answer Marks

2(a) One mark for each pair of rows

Type of printer Laser Inkjet Impact printer

1 Non-impact printer

Line printer

1 Page printer

2

2(b)(i) Five from: • The print head contains a large number of very small nozzles 1 • Ink is fed to each nozzle from a reservoir 1 • The print head fires droplets of ink onto the paper 1 • The print head moves horizontally across the paper 1 Either: • Tiny resistors create heat inside each nozzle 1 • The heat vaporises ink to create a bubble 1 • When the bubble pops the ink is deposited on the page 1 • The collapsing bubble creates a partial vacuum in the nozzle 1 • And ink is drawn from the reservoir ready for printing the next dot 1 Or: • There is a piezo crystal at the back of the ink reservoir of each nozzle 1 • The crystal vibrates when it receives a tiny electric charge 1 • Ink is forced out of the nozzle by the inward vibration 1 • The outward vibration creates a partial vacuum in the nozzle 1 • Replacement ink is pulled into the reservoir 1

Max 5

2(b)(ii) Two from: • The (print head) stepper motor is connected to the print head by a belt 1 • The (print head) stepper motor moves the print head across the paper 1 • The (parking) stepper motor parks the print head assembly when not

in use 1 • The (paper feed)stepper motor turns the rollers that provide the paper feed

// The (paper feed)stepper motor moves the paper in small increments 1

Max 2

2(c)(i) Two from: • External hard drive // External HDD 1 • External flash drive // External SSD 1 • Pen drive 1

Max 2

9608/12 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 4 of 7

Question Answer Marks

2(c)(ii) One from: (External) Hard drive Inexpensive per unit of storage 1 Larger storage capacity than flash drive 1 Or: Pen drive // (External) flash drive No moving parts / noise 1 Low latency // fast access times 1 Robust 1

Max 1

Question Answer Marks

3(a) Definition: Max two from: • The number of distinct values available to encode/represent each

sample 1 • Specified by the number of bits used to encode the data for one

sample 1 • Sometimes referred to as bit depth 1 Explanation: Max two from: • A larger sampling resolution will mean there are more values available to

store each sample 1 • A larger sampling resolution will improve the accuracy of the digitised sound

// A larger sampling resolution will decrease the distortion of the sound 1 • Increased sampling resolution means a smaller quantization error 1

Max 3

3(b)(i) One from: • The number of pixels per unit measurement 1 • The number of pixels in an image 1 • The number of pixels wide by the number of pixels high 1 • Number of pixels per row by the number of rows 1

1

3(b)(ii) 4 1

3(b)(iii) Working: Max two from: • Number of pixels is 8192 × 256 1 • One pixel will be stored as one byte 1 • Number of kilobytes = (8192 × 256) / 1024 1 Answer: One mark: Number of kilobytes = 2048 KB 1

3

3(b)(iv) Two from: • Confirmation that the file is a BMP 1 • File size 1 • Location/offset of image data within the file 1 • Dimensions of the image (in pixels) // image resolution 1 • Colour depth (bits per pixel, 1, 4, 8, 16, 24 or 32) 1 • Type of compression used, if any 1

Max 2

9608/12 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 5 of 7

Question Answer Marks

4(a)(i) Two from: • The hardware is unusable without an OS // hides complexity of hardware

from user 1 • Acts as an interface/ controls communications between user and hardware /

hardware and software // or by example 1 • Provides software platform / environment on which other programs can be

run 1

2

4(a)(ii) One mark for the name and one mark for description. Max two management tasks. • Provides the Human Computer Interface (HCI) 1 Controls communications between user and hardware// or by example 1 • Main memory management 1 Memory protection to ensure that two programs do not try to use the same space // Use of virtual memory // Location of processes within the memory // By example 1 • File / Secondary storage management 1 Maintains directory structures // Provides file naming conventions // Controls access 1 • Peripheral / hardware / device / Input-Output management 1 Installation of appropriate driver software // Controls access to data being sent to/from hardware/peripherals // Controls access to hardware/peripherals // manages communication between devices. 1 • Interrupt handling 1 Identifies priorities of interrupts // Saves data on power outage // Loads appropriate Interrupt Service Routine (ISR) // By example 1 • Security management 1 Makes provision for recovery when data is lost // Provides usernames and passwords // Prevents unauthorised access // Ensures privacy of data 1

Max 4

4(b)(i) File compression software 1

4(b)(ii) Backup software 1

4(b)(iii) Disk defragmenting software 1

4(b)(iv) Anti-virus software 1

Question Answer Marks

5(a)(i) 351 1

5(a)(ii) 355 1

5(a)(iii) 22 1

9608/12 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 6 of 7

Question Answer Marks

5(a)(iv) 86 1

5(b) Op code Operand

0 0 0 1 0 0 1 0 0 1 0 0 0 0 1 1

0 0 0 1 0 1 0 1 0 0 0 0 0 1 1 1

Both correct op codes 1 Operand 0100 0011 1 Operand 0000 0111 1

3

5(c)(i) 14 5E 14 1 5E 1

2

5(c)(ii) LDR #77 LDR 1 #77 1

2

9608/12 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 7 of 7

Question Answer Marks

6(a) Two from: • The file is made available from a web/email/FTP server 1 • The user’s browser is the client software 1 • The client (software browser) requests the file from the server 1 • The desired file is returned to the client computer 1

Max 2

6(b)

1. The user keys in the Uniform Resource Locator (URL) into the browser Software.

2. E // The Domain Name Service (DNS) uses the domain name from the browser to look up the IP address of the web server.

1

3. D // The web server retrieves the page 1

4. F // Sends the web page content to the browser 1

5. B // Browser software renders the page and displays 1

4

6(c)(i) Output1, Output2 1 RunnerID // Runner ID 1

2

6(c)(ii) 6 – 21 1

6(c)(iii) 13 1

6(c)(iv) Checks that the RunnerID entered starts with the characters CAM or VAR only 1

6(c)(v) Two checks from: One mark for check and one mark for description • Format check 1 RunnerID is three letter characters followed by two digit characters //Position is digit characters only 1 • Length check 1 RunnerID has exactly five characters 1 • Range check 1 The value for Position is between1 and (say) 50 1 • Presence check 1 The text box for RunnerID or Position is not empty 1 • Existence check 1 To ensure that RunnerID has been registered 1 • Uniqueness check 1 To ensure no two runners have the same number 1

Max 4

® IGCSE is a registered trademark.

This document consists of 8 printed pages.

© UCLES 2017 [Turn over

Cambridge International Examinations Cambridge International Advanced Subsidiary and Advanced Level

COMPUTER SCIENCE 9608/13 Paper 1 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.

9608/13 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 2 of 8

Question Answer Marks

1(a) Many-to-one 1

1(b)(i) A-NURSE(NurseID, FirstName, FamilyName, WardName) 1

1(b)(ii) • The primary key WardName in the A-WARD table 1• links to the foreign key WardName in the A-NURSE table. 1

2

1(c)(i) Many-to-many relationship 1

1(c)(ii) B-WARD-NURSE(WardName, NurseID) Both attributes (with no additions) 1Joint primary key correctly underlined 1

2

1(c)(iii)

B-WARD-NURSE

B-NURSE B-WARD

Correct relationship between B-NURSE and B-WARD-NURSE 1Correct relationship between B-WARD and B-WARD-NURSE 1

2

1(d)(i) SELECT NurseID, FamilyName 1FROM B-NURSE 1WHERE Specialism = 'THEATRE'; 1

3

1(d)(ii) UPDATE B-NURSE 1SET FamilyName = 'Chi' 1WHERE NurseID = '076'; 1

3

9608/13 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 3 of 8

Question Answer Marks

2(a)(i)

1 A laser beam and a rotating mirror are used to draw an image of the page on the photosensitive drum.

2 C // The image is converted on the drum into an electrostatic charge.

3 Electrostatic charge attracts toner.

4 The charged paper is rolled against the drum.

5 D // The oppositely-charged paper picks up the toner particles from the drum. After picking up the toner, the paper is discharged to stop it clinging to the drum.

6 A // The paper passes through a fuser, which heats up the paper. The toner melts and forms a permanent image on the paper.

7 B // The electrical charge is removed from the drum and the excess toner is collected.

C in the correct place 1DA, 1AB 1

3

2(a)(ii) Inkjet printer 1

2(b) Hard disk drive // HDD 1Solid state drive //SSD // flash memory 1One from: Hard disk Inexpensive per unit of storage 1Larger storage capacity than flash drive 1 Solid state storage No moving parts / noise 1 Robust 1Low latency // Fast read/write time 1

3

9608/13 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 4 of 8

Question Answer Marks

3(a) Sampling rate The number of samples taken per unit time // the number of times the amplitude is measured per unit time 1Increasing the sampling rate will increase the accuracy / precision of the digitised sound // Increasing the sampling rate will result in smaller quantisation errors. 1

2

3(b)(i) Pixel Smallest picture element which can be drawn 1Screen resolution The number of pixels which can be viewed horizontally and vertically on the screen // or by example - A typical screen resolution is 1680 pixels × 1080 pixels. 1

2

3(b)(ii) 8 1

3(b)(iii) Working: Max two from:

• Number of pixels is 2048 × 512 1

• One pixel will be stored as one byte 1

• Number of kilobytes = (2048 × 512) / 1024 1

Answer: One mark:

Number of kilobytes = 1024 KB 1

3

3(b)(iv) One from: • Confirmation that the file is a BMP 1• File size 1• Location/offset of image data within the file 1• Dimensions of the image in pixels // image resolution 1• Colour depth (bits per pixel) 1• Type of compression used, if any 1

1

9608/13 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 5 of 8

Question Answer Marks

4(a)(i) 500 1

4(a)(ii) 496 1

4(a)(iii) 502 1

4(a)(iv) 86 1

4(b) 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1

0 0 0 0 0 1 1 0 0 1 1 0 0 0 0 1

Both correct op codes 1Operand 0001 0001 1 Operand 0110 0001 1

3

4(c) 256 1

4(d)(i) 07 C2 07 1C2 1

2

4(d)(ii) LDI 63 LDI 163 1

2

9608/13 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 6 of 8

Question Answer Marks

5(a)(i) • Count the number of one bits in the first seven bit positions 1• Add a 0 or 1 to bit position 0, to make the count of one bits an odd number 1

2

5(a)(ii) A = 1 B = 1

1

5(a)(iii) Two from: • A parity bit is worked out for each column 1• The computer checks the parity of each bit position in parity byte // the computer

generates copy of the parity byte and compares 1• If incorrect parity then there is an error in the data received // No parity error

means no error in the data received 1• The position of the incorrect bit can be determined 1

2

5(b)(i) 2

5(b)(ii) Three from: • Consider each row in sequence 1• Identify any row with incorrect parity 1• Repeat the process for each column in sequence 1• Identify where a row and column with incorrect parity intersect 1

3

9608/13 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 7 of 8

Question Answer Marks

6(a)

One mark for each correct line from each left hand box to max three marks.

3

6(b)(i) File compression software 1

6(b)(ii) Backup software 1

6(b)(iii) Disk repair software 1

6(b)(iv) Anti-virus software 1

The user selects the Save command to save their spreadsheet file

The user selects the Print command to output their spreadsheet file

The user closes the Spreadsheet program

9608/13 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 8 of 8

Question Answer Marks

7(a) Two from:

• The user’s web browser is the client software 1• The requested web page has program code / script embedded within it 1• This code is interpreted by the web browser 1

2

7(b) Four from:

• The browser parses the URL to obtain the Domain Name 1• The browser software passes the Domain Name to the nearest Domain Name

Server (DNS) 1• The DNS stores a list of Domain Names and matching IP addresses 1• The DNS Name Resolver looks for the Domain Name in its database 1• If found the corresponding IP address is returned to the originator 1• If not found the request is forwarded to another higher level DNS 1• The original DNS adds the returned IP address to its cache 1• The original DNS returns the IP address to the originator 1• The browser uses the IP address to request the required web page from the web

server 1• The web server retrieves the page and delivers it to the originator 1• The browser software interprets the script and displays the web page 1

Max 4

7(c)(i) Message1, Message2 1x 1

2

7(c)(ii) 6 – 19 1

7(c)(iii) 11 1

7(c)(iv) Checks that the product code has not be left blank // presence check on product code

1

7(c)(v) Two checks from: One mark for check and one mark for description • Range check 1 Check the number entered is (say) between 1 and 100 1 • Format check 1 Checks the product code is a particular format // Checks the number has digit

characters only // by example 1 • Length check 1 The number of items has exactly five characters 1 • Existence check 1 To ensure the product code has been assigned 1

Max 4

® IGCSE is a registered trademark.

This document consists of 13 printed pages.

© UCLES 2017 [Turn over

Cambridge International Examinations Cambridge International Advanced Subsidiary and Advanced Level

COMPUTER SCIENCE 9608/21 Paper 2 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.

9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 2 of 13

Question Answer Marks

1(a) Input: • Enter data into the system // get / receive / read data • INPUT MyVar // READFILE MyFile, MyString

Process:

• Manipulate / change data in some way // perform a calculation / find a result

• MyChar ← 'X' // MyNum ← MyNum + 1 Output:

• Send data out from the system // display / print / transmit / show data • OUTPUT "Hello World" // WRITEFILE MyFile, MyString

Mark as follows: 1 mark for each type (in bold) 1 mark for each description and pseudocode example

7

1(b)(i) Boolean 1

1(b)(ii) Logical / Boolean 1

1(b)(iii) Expression Evaluates to

FlagA AND (FlagB OR FlagC) TRUE

FlagA AND (FlagB AND FlagC) FALSE

(NOT FlagA) OR (NOT FlagC) FALSE 1 mark per answer

3

1(c) MyCount ← 100 WHILE MyCount < 201

Output MyCount

MyCount ← MyCount + 2 ENDWHILE 1 mark for each of the following:

• Counter initialisation • While ... End loop • Method for choosing (correct range of) even numbers • Output all even numbers in the range

Note: Counter variable name must be consistent

4

9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 3 of 13

Question Answer Marks

2(a) Stepwise refinement 1

2(b) 1 mark for first 2 data types – String 1 mark for last 2 data types – Boolean 1 mark for each description: PasswordInput Stores password entered UserIDFound True if user ID found in the file PasswordValid True if password entered matches password from file

//Input password matches stored password

5

2(c) 1. LOOP through the file until EOF 2. OR UserIdInput is found 3. READ text line from Password.txt file in a loop 4. SPLIT into UserID and password in a loop 5. IF UserIdInput matches UserID from file THEN in a loop 6. SET UserIDFound to TRUE in a loop 7. IF UserIDFound = TRUE AND PasswordInput matches value

from file THEN 8. Set PasswordValid to TRUE

Mark as follows: 1 mark per functional equivalent of each numbered statement.

8

9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 4 of 13

Question Answer Marks

3 FUNCTION StringClean(Instring STRING) RETURNS STRING

DECLARE NextChar : CHAR

DECLARE OutString : STRING

OutString ← "" // initialise the return string

// loop through Instring to produce OutString

FOR n ← 1 TO LENGTH(InString) // from first to last

NextChar ← MID(Instring, n, 1) //get next character and

NextChar ← LCASE(NextChar) //convert to lower case

IF NextChar >= 'a' AND NextChar <= 'z' //check if alphabetic THEN OutString ← OutString & NextChar //add to OutString ENDIF ENDFOR RETURN OutString // return value

ENDFUNCTION

One mark per underlined word / expression

11

Question Answer Marks

4(a) • The hierarchy of modules • Parameters that are passed between modules // The interface

between the modules / • The sequence • Iteration / selection

One mark per item

3

4(b) FUNCTION CardPayment (ParamA : REAL, ParamB : STRING) RETURNS BOOLEAN One mark per underlined part Order not significant for ParamA and ParamB Function name and parameter names not important but must be present

3

9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 5 of 13

Question Answer Marks

5 Pseudocode solution included here for development and clarification of mark scheme. Programming language example solutions appear in the Appendix. PROCEDURE SearchFile() DECLARE FileData : STRING DECLARE MyArrayRow : INTEGER DECLARE SearchID : STRING MyArrayRow ← 0 / 1 OPEN "Loginfile.txt" FOR READ INPUT SearchID WHILE NOT EOF("Loginfile.txt") READFILE "Loginfile.txt", Filedata IF SearchID = LEFT(FileData,5) THEN LoginEvents[MyArrayRow,1] ← MID(Filedata, 6, 4) LoginEvents[MyArrayRow,2] ← RIGHT(Filedata, 14) MyArrayRow ← MyArrayRow + 1 ENDIF ENDWHILE CLOSEFILE("LoginFile.txt") ENDPROCEDURE 1 mark for each of the following:

1. Procedure heading and ending 2. Declare MyArrayRow as integer // commented in python 3. Initialising MyArrayRow 4. Input SearchID 5. Open file "LoginFile.txt" for input / read 6. Correct loop incorporating EOF() 7. Read a line from the file in a loop 8. Compare SearchID with correct data from file in a loop 9. Assign both values to LoginEvents[MyArray] in a loop 10. Increment MyArrayRow correctly in a loop 11. Close the file not in a loop

10

9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 6 of 13

Question Answer Marks

6(a) Pseudocode solution included here for development and clarification of mark scheme. Programming language solutions appear in the Appendix. FUNCTION ValidatePassword(InString : STRING) RETURNS BOOLEAN DECLARE LCaseChar, UCaseChar, NumChar, n : INTEGER DECLARE NextChar : CHAR DECLARE ReturnFlag : BOOLEAN ReturnFlag ← TRUE LCaseChar ← 0, UCaseChar ← 0, NumChar ← 0 FOR n ← 1 TO LENGTH(InString) NextChar ← MID(InString,n,1) IF NextChar > = 'a' AND NextChar < = 'z' THEN LCaseChar ← LCaseChar + 1 ELSE IF NextChar > = 'A' AND NextChar < = 'Z' THEN UCaseChar ← UCaseChar + 1 ELSE IF NextChar > = '0' AND NextChar < = '9' THEN NumChar ← NumChar + 1 ELSE ReturnFlag ← False //invalid character ENDIF ENDIF ENDIF ENDFOR IF Not (LCaseChar>=2 AND UCaseChar>= 2 AND NumChar>= 3) THEN ReturnFlag ← FALSE ENDIF RETURN (ReturnFlag) ENDFUNCTION 1 mark for each of the following:

1. Correct Function heading and ending 2. Declaring three counter variables (upper, lower, numeric) 3. Initialising counters 4. Correct loop 5. Picking up NextChar from InString 6. Check and count number of lower case 7. Check and count number of upper case

10

9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 7 of 13

Question Answer Marks

6(a) 8. Check and count number of numeric 9. Check for invalid character 10. Combine all four tests into a single Boolean value 11. Returning correct Boolean value

6(b)(i) String1: (e.g. “AAbb123”) One mark for a valid string having:

• at least 2 uppercase alphabetic • at least 2 lowercase alphabetic • at least 3 numeric characters • No other character

String2 – String5: One mark for correct string and explanation (testing different rules of the function) Test strings breaking different rules:

• With incorrect numbers of: • Lower case characters • Upper case characters • Numeric characters

• Containing an invalid character

5

6(b)(ii) White Box 1

6(b)(iii) • Testing may be carried out before the modules are developed // not ready for full testing

• Module stubs contain simple code to provide a known response // temporary replacement for a called module

2

9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 8 of 13

Programming Solutions Programming Code Example Solutions Q5 : Visual Basic Sub SearchFile() Dim FileData As String Dim SearchID As String Dim ArrayIndex As Integer ArrayIndex = 1 FileOpen(1, "LoginFile.txt", OpenMode.Input) SearchID = Console.Readline() Do While Not EOF(1) FileData = LineInput(1) If SearchID = LEFT(FileData, 5) Then LoginEvents(ArrayIndex, 1) = Mid(Filedata, 6, 4) LoginEvents(ArrayIndex, 2) = Right(Filedata, 14) ArrayIndex = ArrayIndex + 1 End If Loop FileClose(1) End Sub Alternative: Sub SearchFile() Dim FileData As String Dim SearchID As String Dim ArrayIndex As Integer Dim MyFile As System.IO.StreamReader ArrayIndex = 1 MyFile = Mycomputer.FileSystem.OpenTextFileReader("Loginfile.txt") SearchID = Console.Readline() Do While MyFile.Peek < > -1 FileData = MyFile.Readline() If SearchID = LEFT(FileData, 5) Then LoginEvents(ArrayIndex, 1) = Mid(Filedata, 6, 4) LoginEvents(ArrayIndex, 2) = Right(Filedata, 14) ArrayIndex = ArrayIndex + 1 End If Loop MyFile.Close End Sub

9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 9 of 13

Q5 : Pascal Procedure SearchFile(); var FileData : String; var SearchID : String; var ArrayRow : Integer; Var MyFile : Text; Begin ArrayRow := 1; Assign(MyFile, "Loginfile.txt"); Reset(MyFile); Readln(SearchID); While NOT EOF(MyFile) do Begin Readln(MyFile, FileData) IF SearchID = LeftStr(FileData,5) then Begin LoginEvents[ArrayRow,1] = Copy(FileData,6,4); LoginEvents[ArrayRow,2] = Rightstr(FileData,14); ArrayRow = ArrayRow + 1 End; End; Close(MyFile); End.

9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 10 of 13

Q5 : Python def SearchFile(): # FileData : STRING # ArrayRow : INTEGER # SearchID : STRING ArrayRow = 0 MyFile = open("Loginfile.txt", 'r') SearchID = input() FileData = MyFile.readline() While FileData != "" If SearchID = = FileData[:5] #First 5 characters LoginEvents[ArrayRow][1] = FileData[5:9] #next 4 characters LoginEvents[ArrayRow][2] = FileData[-14:] #last 14 characters ArrayRow = ArrayRow + 1 FileData = MyFile.readline() myFile.close() return() Alternative: def SearchFile(): # FileData : STRING # ArrayRow : INTEGER # SearchID : STRING ArrayRow = 0 Myfile = open("Loginfile.txt", 'r') SearchID = input() For FileData in MyFile IF SearchID = = FileData[:5] #First 5 characters LoginEvents[ArrayRow][1] = FileData[5:9] #next 4 characters LoginEvents[ArrayRow][2] = FileData[-14:] #last 14 characters ArrayRow = ArrayRow + 1 MyFile.close() return()

9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 11 of 13

Q6 (a): Visual Basic Function ValidatePassword(InString As String) As Boolean Dim LCaseChar, UCaseChar, NumChar As Integer Dim NextChar As Char Dim ReturnFlag As Boolean Dim n As Integer ReturnFlag = TRUE LCaseChar = 0 UCaseChar = 0 NumChar = 0 For n = 1 to Len(InString) NextChar = Mid(InString, n, 1) If NextChar > = 'a' And NextChar < = 'z' Then LCaseChar = LCaseChar + 1 Else If NextChar > = 'A' And NextChar < = 'Z' Then UCaseChar = UCaseChar + 1 Else If NextChar > = '0' And NextChar < = '9' Then NumChar = NumChar + 1 Else ReturnFlag = False //invalid character End If End If End If Next If NOT (LCaseChar > = 2 And UCaseChar > = 2 And NumChar > = 3)Then ReturnFlag = FALSE End If Return(ReturnFlag) End Function

9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 12 of 13

Q6 (a): Pascal Function ValidatePassword(InString : String): Boolean; Var LCaseChar, UCaseChar, NumChar : Integer; Var NextChar : Char; Var ReturnFlag : Boolean; Var n : Integer; begin ReturnFlag := TRUE; LCaseChar := 0; UCaseChar := 0; NumChar := 0; For n := 1 to Length(InString) do begin NextChar := Copy(InString,n,1); If NextChar > = 'a' And NextChar < = 'z' Then LCaseChar := LCaseChar + 1 Else If NextChar > = 'A' AND NextChar < = 'Z' Then UCaseChar := UCaseChar + 1 Else If NextChar > = '0' AND NextChar < = '9' Then NumChar := NumChar + 1 Else ReturnFlag := False //invalid character end If NOT(LCaseChar > = 2 And UCaseChar > = 2 And NumChar > =3)then ReturnFlag := False; ValidatePassword := ReturnFlag end;

9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 13 of 13

Q6 (a): Python def ValidatePassword(InString): # lCaseChar, uCaseChar, numChar : INTEGER # nextChar : CHAR # returnFlag : BOOLEAN # n : INTEGER returnFlag = TRUE lCaseChar = 0 uCaseChar = 0 numChar = 0 for n in range (0, Len(InString)) nextChar = InString[n] If nextChar > = 'a' and nextChar < = 'z': lCaseChar = lCaseChar + 1 ELSE: IF nextChar > = 'A' and nextChar < = 'Z': uCaseChar = uCaseChar + 1 ELSE: IF nextChar > = '0' and nextChar < = '9': numChar = numChar + 1 ELSE: returnFlag = False //invalid character IF Not (lCaseChar > = 2 and uCaseChar > = 2 and numChar > = 3): returnFlag = FALSE Return (returnFlag) #next code block

® IGCSE is a registered trademark.

This document consists of 8 printed pages.

© UCLES 2017 [Turn over

Cambridge International Examinations Cambridge International Advanced Subsidiary and Advanced Level

COMPUTER SCIENCE 9608/22 Paper 2 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.

9608/22 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 2 of 8

Question Answer Marks

1(a) Item Statement Input Process Output

1 SomeChars = "Hello World"

2 OUTPUT RIGHT(String1,5)

3 READFILE (MyFile, String2)

4 WRITEFILE (MyFile, "Data is " & String2)

Mark as follows: Row 1 as shown Row 2 no marks if tick in Input column, otherwise 1 mark per tick Row 3 as shown Row 4 no marks if tick in Input column, otherwise 1 mark per tick

6

1(b)(i) • Integer / Real / Single / Double / Floating Point / Float • Boolean

2

1(b)(ii) Expression Evaluates to

(FlagA AND FlagB) OR FlagC TRUE

FlagA AND (FlagB OR FlagC) TRUE

(NOT FlagA) OR (NOT FlagC) FALSE

1 mark per answer

3

1(c) MyCount ← 101 REPEAT OUTPUT MyCount MyCount ← MyCount + 2 UNTIL MyCount > 199 1 mark for each of the following: • Counter initialisation • Repeat Until loop • Method for choosing (correct range of) odd numbers • Output all odd numbers in the range Note: Counter variable name must be consistent

4

9608/22 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 3 of 8

Question Answer Marks

2(a) • to increase the level of detail of an algorithm / design...

// breaking down a problem / module / task into smaller parts

• from which the task may be programmed 1 mark per underlined phrase or equivalent

2

2(b) 1 mark for first 3 data types – String 1 mark for last data type – Boolean 1 mark for each description: FileUserID Stores (User) ID from file FilePreferredName Stores (preferred) name from file IDFoundFlag True if (User) ID found in file // False if (User) ID not found in

file // If SearchUserID matches FileUserID

5

2(c) 1. LOOP through the file until EOF() 2. OR SearchUserId is found 3. READ text line from UserNames.txt file in a loop 4. EXTRACT FileUserID in a loop 5. IF SearchUserId matches FileUserID THEN in a loop 6. SET FilePreferredName to the name from the file 7. Check if User ID found not in a loop 8. OUTPUT appropriate message for both conditions 1 mark per functional equivalent of each numbered statement.

Max 8

9608/22 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 4 of 8

Question Answer Marks

3 FUNCTION ExCamel (InString: STRING) RETURNS STRING

DECLARE NextChar : CHAR

DECLARE OutString : STRING

DECLARE n : INTEGER

OutString ← "" // initialise the return string

// loop through InString to produce OutString

FOR n ← 1 TO LENGTH(InString) // from first to last

NextChar ← MID(InString, n, 1) // get next character

IF NextChar >= 'A' AND NextChar <= 'Z' // check if upper case // NextChar = UCASE(NextChar)

THEN

IF n > 1 // if not first character

THEN

OutString ← OutString & " " // add space to OutString ENDIF NextChar ← LCASE(NextChar) // make NextChar lower case ENDIF

OutString ← OutString & NextChar // add Nextchar to OutString ENDFOR

RETURN OutString // return value

ENDFUNCTION

1 mark per underlined word / expression

Max 11

9608/22 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 5 of 8

Question Answer Marks

4(a) • Functions • Procedures • Global / Local variables 1 mark per item

Max 2

4(b) Name of parameter passing method

Value output Explanation

(Call) by reference 5 • The address of the variable is passed. • Original value is changed when parameter

changed in called module.

(Call) by value 4 • A copy of the variable itself is passed. • Original value not changed when

parameter changed in called module. Mark as follows:

• 1 mark for each name and value • 1 mark per bullet in explanation

6

Question Answer Marks

5(a)(i) • Any character except colon, space or any alpha-numeric • Reason: character is not in the login information strings

2

5(a)(ii) DECLARE LogArray : ARRAY[1 : 20] OF STRING 1 mark per underline

2

9608/22 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 6 of 8

Question Answer Marks

5(b) Pseudocode solution included here for development and clarification of mark scheme. Programming language example solutions appear in the Appendix.

PROCEDURE LogEvents()

DECLARE FileData : STRING

DECLARE ArrayIndex : INTEGER

OPENFILE "LoginFile.txt" FOR APPEND

FOR ArrayIndex ← 1 TO 20 // IF LogArray[ArrayIndex]<> "****"

THEN

FileData ← LogArray[ArrayIndex]

WRITEFILE ("LoginFile.txt", FileData)

ENDIF

ENDFOR

CLOSEFILE("LoginFile.txt")

ENDPROCEDURE 1 mark for each of the following: 1. Procedure heading and ending 2. Declare ArrayIndex as integer // commented in python 3. Open file 'LoginFile' for append 4. Correct loop 5. extract data from array in a loop 6. check for unused element in a loop 7. write data to file in a loop 8. Close the file outside the loop

8

9608/22 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 7 of 8

Question Answer Marks

6(a) Pseudocode solution included here for development and clarification of mark scheme. Programming language example solutions appear in the Appendix. FUNCTION ValidateRegistration(Registration : STRING) RETURNS BOOLEAN DECLARE UCaseChar, NumChar : INTEGER DECLARE NextChar : CHAR DECLARE ReturnFlag : BOOLEAN DECLARE n : INTEGER ReturnFlag ← TRUE ValidateRegistration ← True IF LEN(Registration) < 6 OR LEN(Registration) > 9 //check length THEN ReturnFlag ← False ELSE FOR n ← 1 TO 3 //check for 3 upper case alpha NextChar ← MID(Registration, n, 1) IF NextChar < 'A' AND NextChar > 'Z' THEN ReturnFlag ← False ENDIF ENDFOR FOR n ← 4 TO 5 //check for 2 numeric NextChar ← MID(Registration, n, 1) IF NextChar < '0' AND NextChar > '9 THEN ReturnFlag ← False ENDIF ENDFOR FOR n ← 6 TO LEN(Registration) //check remaining characters NextChar ← MID(Registration, n, 1) IF NextChar < 'A' AND NextChar > 'Z' THEN ReturnFlag ← False ENDIF ENDFOR ENDIF RETURN (ReturnFlag) ENDFUNCTION

Max 9

9608/22 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 8 of 8

Question Answer Marks

6(a) 1 mark for each of the following: 1. Correct Function heading and ending 2. Check for correct length 3. Extract first three characters 4. Check first three characters are capitals 5. Extract characters four and five 6. Check characters four and five are numeric 7. Extract remaining characters 8. Check remaining characters are capitals 9. Combine all four tests results into a single Boolean value 10. Return a Boolean value

6(b) String1: (for example, "ABC12XYZ") One mark for a valid string having: • Correct length (between 6 and 9 characters) • 3 capital letters followed by • 2 numeric characters followed by • between 1 and 4 capital letters String2 to String5: 1 mark for each string and explanation (testing different rules of the function) Test strings breaking one different rules: • Incorrect length • With incorrect number of capital letters at the start • With non-numeric characters in positions 4 and 5 • With incorrect number of capital letters at the end • Containing an invalid character (not alpha-numeric)

5

® IGCSE is a registered trademark.

This document consists of 13 printed pages.

© UCLES 2017 [Turn over

Cambridge International Examinations Cambridge International Advanced Subsidiary and Advanced Level

COMPUTER SCIENCE 9608/23 Paper 2 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.

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 2 of 13

Question Answer Marks

1(a) Input: • Enter data into the system // get / receive / read data • INPUT MyVar // READFILE MyFile, MyString

Process:

• Manipulate / change data in some way // perform a calculation / find a result

• MyChar ← 'X' // MyNum ← MyNum + 1 Output:

• Send data out from the system // display / print / transmit / show data • OUTPUT "Hello World" // WRITEFILE MyFile, MyString

Mark as follows: 1 mark for each type (in bold) 1 mark for each description and pseudocode example

7

1(b)(i) Boolean 1

1(b)(ii) Logical / Boolean 1

1(b)(iii) Expression Evaluates to

FlagA AND (FlagB OR FlagC) TRUE

FlagA AND (FlagB AND FlagC) FALSE

(NOT FlagA) OR (NOT FlagC) FALSE 1 mark per answer

3

1(c) MyCount ← 100 WHILE MyCount < 201

Output MyCount

MyCount ← MyCount + 2 ENDWHILE 1 mark for each of the following:

• Counter initialisation • While ... End loop • Method for choosing (correct range of) even numbers • Output all even numbers in the range

Note: Counter variable name must be consistent

4

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 3 of 13

Question Answer Marks

2(a) Stepwise refinement 1

2(b) 1 mark for first 2 data types – String 1 mark for last 2 data types – Boolean 1 mark for each description: PasswordInput Stores password entered UserIDFound True if user ID found in the file PasswordValid True if password entered matches password from file

//Input password matches stored password

5

2(c) 1. LOOP through the file until EOF 2. OR UserIdInput is found 3. READ text line from Password.txt file in a loop 4. SPLIT into UserID and password in a loop 5. IF UserIdInput matches UserID from file THEN in a loop 6. SET UserIDFound to TRUE in a loop 7. IF UserIDFound = TRUE AND PasswordInput matches value

from file THEN 8. Set PasswordValid to TRUE

Mark as follows: 1 mark per functional equivalent of each numbered statement.

8

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 4 of 13

Question Answer Marks

3 FUNCTION StringClean(Instring STRING) RETURNS STRING

DECLARE NextChar : CHAR

DECLARE OutString : STRING

OutString ← "" // initialise the return string

// loop through Instring to produce OutString

FOR n ← 1 TO LENGTH(InString) // from first to last

NextChar ← MID(Instring, n, 1) //get next character and

NextChar ← LCASE(NextChar) //convert to lower case

IF NextChar >= 'a' AND NextChar <= 'z' //check if alphabetic THEN OutString ← OutString & NextChar //add to OutString ENDIF ENDFOR RETURN OutString // return value

ENDFUNCTION

One mark per underlined word / expression

11

Question Answer Marks

4(a) • The hierarchy of modules • Parameters that are passed between modules // The interface

between the modules / • The sequence • Iteration / selection

One mark per item

3

4(b) FUNCTION CardPayment (ParamA : REAL, ParamB : STRING) RETURNS BOOLEAN One mark per underlined part Order not significant for ParamA and ParamB Function name and parameter names not important but must be present

3

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 5 of 13

Question Answer Marks

5 Pseudocode solution included here for development and clarification of mark scheme. Programming language example solutions appear in the Appendix. PROCEDURE SearchFile() DECLARE FileData : STRING DECLARE MyArrayRow : INTEGER DECLARE SearchID : STRING MyArrayRow ← 0 / 1 OPEN "Loginfile.txt" FOR READ INPUT SearchID WHILE NOT EOF("Loginfile.txt") READFILE "Loginfile.txt", Filedata IF SearchID = LEFT(FileData,5) THEN LoginEvents[MyArrayRow,1] ← MID(Filedata, 6, 4) LoginEvents[MyArrayRow,2] ← RIGHT(Filedata, 14) MyArrayRow ← MyArrayRow + 1 ENDIF ENDWHILE CLOSEFILE("LoginFile.txt") ENDPROCEDURE 1 mark for each of the following:

1. Procedure heading and ending 2. Declare MyArrayRow as integer // commented in python 3. Initialising MyArrayRow 4. Input SearchID 5. Open file "LoginFile.txt" for input / read 6. Correct loop incorporating EOF() 7. Read a line from the file in a loop 8. Compare SearchID with correct data from file in a loop 9. Assign both values to LoginEvents[MyArray] in a loop 10. Increment MyArrayRow correctly in a loop 11. Close the file not in a loop

10

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 6 of 13

Question Answer Marks

6(a) Pseudocode solution included here for development and clarification of mark scheme. Programming language solutions appear in the Appendix. FUNCTION ValidatePassword(InString : STRING) RETURNS BOOLEAN DECLARE LCaseChar, UCaseChar, NumChar, n : INTEGER DECLARE NextChar : CHAR DECLARE ReturnFlag : BOOLEAN ReturnFlag ← TRUE LCaseChar ← 0, UCaseChar ← 0, NumChar ← 0 FOR n ← 1 TO LENGTH(InString) NextChar ← MID(InString,n,1) IF NextChar > = 'a' AND NextChar < = 'z' THEN LCaseChar ← LCaseChar + 1 ELSE IF NextChar > = 'A' AND NextChar < = 'Z' THEN UCaseChar ← UCaseChar + 1 ELSE IF NextChar > = '0' AND NextChar < = '9' THEN NumChar ← NumChar + 1 ELSE ReturnFlag ← False //invalid character ENDIF ENDIF ENDIF ENDFOR IF Not (LCaseChar>=2 AND UCaseChar>= 2 AND NumChar>= 3) THEN ReturnFlag ← FALSE ENDIF RETURN (ReturnFlag) ENDFUNCTION 1 mark for each of the following:

1. Correct Function heading and ending 2. Declaring three counter variables (upper, lower, numeric) 3. Initialising counters 4. Correct loop 5. Picking up NextChar from InString 6. Check and count number of lower case 7. Check and count number of upper case

10

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 7 of 13

Question Answer Marks

6(a) 8. Check and count number of numeric 9. Check for invalid character 10. Combine all four tests into a single Boolean value 11. Returning correct Boolean value

6(b)(i) String1: (e.g. “AAbb123”) One mark for a valid string having:

• at least 2 uppercase alphabetic • at least 2 lowercase alphabetic • at least 3 numeric characters • No other character

String2 – String5: One mark for correct string and explanation (testing different rules of the function) Test strings breaking different rules:

• With incorrect numbers of: • Lower case characters • Upper case characters • Numeric characters

• Containing an invalid character

5

6(b)(ii) White Box 1

6(b)(iii) • Testing may be carried out before the modules are developed // not ready for full testing

• Module stubs contain simple code to provide a known response // temporary replacement for a called module

2

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 8 of 13

Programming Solutions Programming Code Example Solutions Q5 : Visual Basic Sub SearchFile() Dim FileData As String Dim SearchID As String Dim ArrayIndex As Integer ArrayIndex = 1 FileOpen(1, "LoginFile.txt", OpenMode.Input) SearchID = Console.Readline() Do While Not EOF(1) FileData = LineInput(1) If SearchID = LEFT(FileData, 5) Then LoginEvents(ArrayIndex, 1) = Mid(Filedata, 6, 4) LoginEvents(ArrayIndex, 2) = Right(Filedata, 14) ArrayIndex = ArrayIndex + 1 End If Loop FileClose(1) End Sub Alternative: Sub SearchFile() Dim FileData As String Dim SearchID As String Dim ArrayIndex As Integer Dim MyFile As System.IO.StreamReader ArrayIndex = 1 MyFile = Mycomputer.FileSystem.OpenTextFileReader("Loginfile.txt") SearchID = Console.Readline() Do While MyFile.Peek < > -1 FileData = MyFile.Readline() If SearchID = LEFT(FileData, 5) Then LoginEvents(ArrayIndex, 1) = Mid(Filedata, 6, 4) LoginEvents(ArrayIndex, 2) = Right(Filedata, 14) ArrayIndex = ArrayIndex + 1 End If Loop MyFile.Close End Sub

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 9 of 13

Q5 : Pascal Procedure SearchFile(); var FileData : String; var SearchID : String; var ArrayRow : Integer; Var MyFile : Text; Begin ArrayRow := 1; Assign(MyFile, "Loginfile.txt"); Reset(MyFile); Readln(SearchID); While NOT EOF(MyFile) do Begin Readln(MyFile, FileData) IF SearchID = LeftStr(FileData,5) then Begin LoginEvents[ArrayRow,1] = Copy(FileData,6,4); LoginEvents[ArrayRow,2] = Rightstr(FileData,14); ArrayRow = ArrayRow + 1 End; End; Close(MyFile); End.

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 10 of 13

Q5 : Python def SearchFile(): # FileData : STRING # ArrayRow : INTEGER # SearchID : STRING ArrayRow = 0 MyFile = open("Loginfile.txt", 'r') SearchID = input() FileData = MyFile.readline() While FileData != "" If SearchID = = FileData[:5] #First 5 characters LoginEvents[ArrayRow][1] = FileData[5:9] #next 4 characters LoginEvents[ArrayRow][2] = FileData[-14:] #last 14 characters ArrayRow = ArrayRow + 1 FileData = MyFile.readline() myFile.close() return() Alternative: def SearchFile(): # FileData : STRING # ArrayRow : INTEGER # SearchID : STRING ArrayRow = 0 Myfile = open("Loginfile.txt", 'r') SearchID = input() For FileData in MyFile IF SearchID = = FileData[:5] #First 5 characters LoginEvents[ArrayRow][1] = FileData[5:9] #next 4 characters LoginEvents[ArrayRow][2] = FileData[-14:] #last 14 characters ArrayRow = ArrayRow + 1 MyFile.close() return()

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 11 of 13

Q6 (a): Visual Basic Function ValidatePassword(InString As String) As Boolean Dim LCaseChar, UCaseChar, NumChar As Integer Dim NextChar As Char Dim ReturnFlag As Boolean Dim n As Integer ReturnFlag = TRUE LCaseChar = 0 UCaseChar = 0 NumChar = 0 For n = 1 to Len(InString) NextChar = Mid(InString, n, 1) If NextChar > = 'a' And NextChar < = 'z' Then LCaseChar = LCaseChar + 1 Else If NextChar > = 'A' And NextChar < = 'Z' Then UCaseChar = UCaseChar + 1 Else If NextChar > = '0' And NextChar < = '9' Then NumChar = NumChar + 1 Else ReturnFlag = False //invalid character End If End If End If Next If NOT (LCaseChar > = 2 And UCaseChar > = 2 And NumChar > = 3)Then ReturnFlag = FALSE End If Return(ReturnFlag) End Function

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 12 of 13

Q6 (a): Pascal Function ValidatePassword(InString : String): Boolean; Var LCaseChar, UCaseChar, NumChar : Integer; Var NextChar : Char; Var ReturnFlag : Boolean; Var n : Integer; begin ReturnFlag := TRUE; LCaseChar := 0; UCaseChar := 0; NumChar := 0; For n := 1 to Length(InString) do begin NextChar := Copy(InString,n,1); If NextChar > = 'a' And NextChar < = 'z' Then LCaseChar := LCaseChar + 1 Else If NextChar > = 'A' AND NextChar < = 'Z' Then UCaseChar := UCaseChar + 1 Else If NextChar > = '0' AND NextChar < = '9' Then NumChar := NumChar + 1 Else ReturnFlag := False //invalid character end If NOT(LCaseChar > = 2 And UCaseChar > = 2 And NumChar > =3)then ReturnFlag := False; ValidatePassword := ReturnFlag end;

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 13 of 13

Q6 (a): Python def ValidatePassword(InString): # lCaseChar, uCaseChar, numChar : INTEGER # nextChar : CHAR # returnFlag : BOOLEAN # n : INTEGER returnFlag = TRUE lCaseChar = 0 uCaseChar = 0 numChar = 0 for n in range (0, Len(InString)) nextChar = InString[n] If nextChar > = 'a' and nextChar < = 'z': lCaseChar = lCaseChar + 1 ELSE: IF nextChar > = 'A' and nextChar < = 'Z': uCaseChar = uCaseChar + 1 ELSE: IF nextChar > = '0' and nextChar < = '9': numChar = numChar + 1 ELSE: returnFlag = False //invalid character IF Not (lCaseChar > = 2 and uCaseChar > = 2 and numChar > = 3): returnFlag = FALSE Return (returnFlag) #next code block

® 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/31 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.

9608/31 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 2 of 7

Question Answer Marks

1(a)(i) DECLARE Book : LibraryBookRecord 1

1(a)(ii) Book.Title ← "Dune" 1

1(b) TYPE LibraryBookRecord DECLARE ISBN : INTEGER DECLARE Title : STRING DECLARE Genre : (Fiction, Non-Fiction) 1 DECLARE NumberOfLoans : 1 .. 99 1ENDTYPE mark for correct declaration and first two fields (note: only if attempt at modification) 1

3

1(c)(i) 6715 1

1(c)(ii) 8216 1

1(c)(iii) 88 1

1(c)(iv) FALSE 1

1(d)(i) Temp2 ← 22 1

1(d)(ii) IntPointer ← @Temp1 1

1(d)(iii) IntPointer^ ← Temp2 1

9608/31 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 3 of 7

Question Answer Marks

2(a)(i) Worm 1

2(a)(ii) Phishing 1

2(a)(iii) Malicious software that replicates by inserting a copy of itself (1) into a file of data (1)

2

2(b) Example: No up-to-date anti-virus (or equivalent) software Regular virus scans not performed Operating system not up-to-date Attachments/suspicious links clicked on 1 mark for any valid vulnerability

Max 2

2(c)(i) public 1

2(c)(ii) Bob sends his digital certificate Digital certificate contains Bob’s public key Successful decryption of certificate using CA’s public key provides legitimacy 1 mark for any valid point – max 2

2

2(c)(iii)

The person performing the action

What that person does

Anna Requests Bob’s public key.

Bob Sends Anna his public key. 1

Anna Encrypts email with Bob’s public key. 1

Anna Sends the email to Bob.

Bob Decrypts email. Using his private key.

11

4

9608/31 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 4 of 7

Question Answer Marks

3(a) X = A.(B + (B . C)) B.C 1B + B.C 1A. 1

3

3(b)

A B C Working Space X 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 1 mark first four entries, 1 mark for the last four entries

2

3(c)(i) AB

00 01 11 10

C 0 0 0 0 1

1 0 0 1 1

1

3(c)(ii)

AB

00 01 11 10

C 0 0 0 0 1

1 0 0 1 1

2

3(c)(iii) X = A.B + A.C 1 1

2

3(d) X = A.(B + (B . C)) X = A.(B + C ) 1X = A.B + A.C 1 (dependent mark – must be correct

outcome from previous line)

2

9608/31 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 5 of 7

Question Answer Marks

4(a) Example: Speed of access Just used as a look-up file No need for any serial or sequential processing 1 mark for any valid point

1

4(b)(i)

CustomerID RecordKey

802139 2139

700004 4

689998 89998

102139 2139

1

4(b)(ii) Minimum value: 0 1Maximum value: 99999 1

2

4(b)(iii) PROCEDURE InsertRecord(CustomerID : INTEGER) RecordKey ← CustomerID MOD 100000 Success ← FALSE // Find position for new record and insert it REPEAT IF record at position RecordKey is empty THEN Insert new record at position RecordKey Success ← TRUE ELSE IF RecordKey = 99999 THEN RecordKey ← 0 ELSE RecordKey ← RecordKey + 1 ENDIF ENDIF UNTIL Success = TRUE ENDPROCEDURE

4

4(c)(i) For security If file is hacked then encrypted PIN cannot be used Only encrypted PINs are transmitted and compared 1 mark for any valid point

Max 2

4(c)(ii) 1. Customer ID is read from card 2. Customer enters PIN 3. Customer PIN is encrypted 4. Customer ID is hashed 5. Customer record is located in file 6. PIN is checked against PIN in record 7. If match then transaction can proceed

3

9608/31 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 6 of 7

Question Answer Marks

5(a)(i) Packet: Both web page and web page request are split into packets 1Each packet is sent individually from device to device 1

2

5(a)(ii) Router: Transmit packets Contain connections to many other routers When packets arrive at router, router decides where next to send packet 1 mark for any valid point

Max 2

5(a)(iii) TCP/IP: Is the protocol 1Rules for communication between web server and browser 1

2

5(b)(i) Two from: Picture and sound not synchronised 1Interruptions // video not continuous 1Can be degraded by other competing traffic 1

Max 2

5(b)(ii) Dedicated communications channel between the two communicating devices 1Established prior to start of communication // removal of links at end of communication 1

2

5(b)(iii) In packet switching, packets can take different routes and may not arrive in order Will arrive in order (only one route) As packets can take many different routes / share paths with others can be delayed Dedicated circuit has full bandwidth No loss of synch 1 mark for any valid point

Max 3

9608/31 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 7 of 7

Question Answer Marks

6(a)(i) Control system 1

6(a)(ii) Use of actuators means that the system is controlling 1

6(b) System wastes processor time checking for values that are not changing 1Some sensor input needs to be acted upon immediately 1

2

6(c)(i) Interrupts need to be disabled so that the process of dealing with an interrupt is itself not interrupted

1

6(c)(ii) After handling the interrupt interrupts need to be enabled so that further interrupts can be dealt with

1

6(c)(iii) Content of registers 1 Placed on stack 1

2

6(c)(iv) Changing sensor value dealt with as soon as it happens 1Processor needs to check sensor only when an interrupt occurs 1

2

6(c)(v) AND #B0000001000000000 // AND #&0200 // AND #512 Op code 1Operand 1

2

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

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

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

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

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

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

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

® 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/33 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.

9608/33 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 2 of 7

Question Answer Marks

1(a)(i) DECLARE Book : LibraryBookRecord 1

1(a)(ii) Book.Title ← "Dune" 1

1(b) TYPE LibraryBookRecord DECLARE ISBN : INTEGER DECLARE Title : STRING DECLARE Genre : (Fiction, Non-Fiction) 1 DECLARE NumberOfLoans : 1 .. 99 1ENDTYPE mark for correct declaration and first two fields (note: only if attempt at modification) 1

3

1(c)(i) 6715 1

1(c)(ii) 8216 1

1(c)(iii) 88 1

1(c)(iv) FALSE 1

1(d)(i) Temp2 ← 22 1

1(d)(ii) IntPointer ← @Temp1 1

1(d)(iii) IntPointer^ ← Temp2 1

9608/33 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 3 of 7

Question Answer Marks

2(a)(i) Worm 1

2(a)(ii) Phishing 1

2(a)(iii) Malicious software that replicates by inserting a copy of itself (1) into a file of data (1)

2

2(b) Example: No up-to-date anti-virus (or equivalent) software Regular virus scans not performed Operating system not up-to-date Attachments/suspicious links clicked on 1 mark for any valid vulnerability

Max 2

2(c)(i) public 1

2(c)(ii) Bob sends his digital certificate Digital certificate contains Bob’s public key Successful decryption of certificate using CA’s public key provides legitimacy 1 mark for any valid point – max 2

2

2(c)(iii)

The person performing the action

What that person does

Anna Requests Bob’s public key.

Bob Sends Anna his public key. 1

Anna Encrypts email with Bob’s public key. 1

Anna Sends the email to Bob.

Bob Decrypts email. Using his private key.

11

4

9608/33 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 4 of 7

Question Answer Marks

3(a) X = A.(B + (B . C)) B.C 1B + B.C 1A. 1

3

3(b)

A B C Working Space X 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 1 mark first four entries, 1 mark for the last four entries

2

3(c)(i) AB

00 01 11 10

C 0 0 0 0 1

1 0 0 1 1

1

3(c)(ii)

AB

00 01 11 10

C 0 0 0 0 1

1 0 0 1 1

2

3(c)(iii) X = A.B + A.C 1 1

2

3(d) X = A.(B + (B . C)) X = A.(B + C ) 1X = A.B + A.C 1 (dependent mark – must be correct

outcome from previous line)

2

9608/33 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 5 of 7

Question Answer Marks

4(a) Example: Speed of access Just used as a look-up file No need for any serial or sequential processing 1 mark for any valid point

1

4(b)(i)

CustomerID RecordKey

802139 2139

700004 4

689998 89998

102139 2139

1

4(b)(ii) Minimum value: 0 1Maximum value: 99999 1

2

4(b)(iii) PROCEDURE InsertRecord(CustomerID : INTEGER) RecordKey ← CustomerID MOD 100000 Success ← FALSE // Find position for new record and insert it REPEAT IF record at position RecordKey is empty THEN Insert new record at position RecordKey Success ← TRUE ELSE IF RecordKey = 99999 THEN RecordKey ← 0 ELSE RecordKey ← RecordKey + 1 ENDIF ENDIF UNTIL Success = TRUE ENDPROCEDURE

4

4(c)(i) For security If file is hacked then encrypted PIN cannot be used Only encrypted PINs are transmitted and compared 1 mark for any valid point

Max 2

4(c)(ii) 1. Customer ID is read from card 2. Customer enters PIN 3. Customer PIN is encrypted 4. Customer ID is hashed 5. Customer record is located in file 6. PIN is checked against PIN in record 7. If match then transaction can proceed

3

9608/33 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 6 of 7

Question Answer Marks

5(a)(i) Packet: Both web page and web page request are split into packets 1Each packet is sent individually from device to device 1

2

5(a)(ii) Router: Transmit packets Contain connections to many other routers When packets arrive at router, router decides where next to send packet 1 mark for any valid point

Max 2

5(a)(iii) TCP/IP: Is the protocol 1Rules for communication between web server and browser 1

2

5(b)(i) Two from: Picture and sound not synchronised 1Interruptions // video not continuous 1Can be degraded by other competing traffic 1

Max 2

5(b)(ii) Dedicated communications channel between the two communicating devices 1Established prior to start of communication // removal of links at end of communication 1

2

5(b)(iii) In packet switching, packets can take different routes and may not arrive in order Will arrive in order (only one route) As packets can take many different routes / share paths with others can be delayed Dedicated circuit has full bandwidth No loss of synch 1 mark for any valid point

Max 3

9608/33 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 7 of 7

Question Answer Marks

6(a)(i) Control system 1

6(a)(ii) Use of actuators means that the system is controlling 1

6(b) System wastes processor time checking for values that are not changing 1Some sensor input needs to be acted upon immediately 1

2

6(c)(i) Interrupts need to be disabled so that the process of dealing with an interrupt is itself not interrupted

1

6(c)(ii) After handling the interrupt interrupts need to be enabled so that further interrupts can be dealt with

1

6(c)(iii) Content of registers 1 Placed on stack 1

2

6(c)(iv) Changing sensor value dealt with as soon as it happens 1Processor needs to check sensor only when an interrupt occurs 1

2

6(c)(v) AND #B0000001000000000 // AND #&0200 // AND #512 Op code 1Operand 1

2

® IGCSE is a registered trademark.

This document consists of 13 printed pages.

© UCLES 2017 [Turn over

Cambridge International Examinations Cambridge International Advanced Subsidiary and Advanced Level

COMPUTER SCIENCE 9608/41 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.

9608/41 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 2 of 13

Question Answer Marks

1(a) Label Op

code Operand Comment

START: IN // INPUT character

STO CHAR // store in CHAR 1

LDM #65 // Initialise ACC (ASCII value for 'A' is 65)

1

LOOP: OUT // OUTPUT ACC 1 + 1

CMP CHAR // compare ACC with CHAR 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

CHAR:

8

1(b) START: LDD NUMBER 1

AND MASK // set to zero all bits except sign bit

1

CMP #0 // compare with 0 1

JPN ELSE // if not equal jump to ELSE 1

THEN: LDM #80 // load ACC with 'P' (ASCII value 80) 1

JMP ENDIF

ELSE: LDM #78 // load ACC with 'N' (ASCII value 78)

ENDIF: OUT //output character 1

END

NUMBER: B00000101 // integer to be tested

MASK: B10000000 // show value of mask in binary here

1

7

9608/41 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 3 of 13

Question Answer Marks

2(a) 1 mark for the declaration of the array. 1 mark for assigning a 0 to Customer ID (CustomerID ← 0) 1 mark for getting the correct record (Customer[x].) 1 mark for setting up a loop to go from 0 to 199

DECLARE Customer : ARRAY[0 : 199] OF CustomerRecord 1

FOR x ← 0 TO 199 1

Customer[x].CustomerID ← 0 1+1

ENDFOR

4

2(b)(i) PROCEDURE InsertRecord(BYVAL NewCustomer : CustomerRecord) TableFull ← FALSE // generate hash value Index ← Hash(NewCustomer.CustomerID) 1 Pointer ← Index // take a copy of index // find a free table element WHILE Customer[Pointer].CustomerID > 0 1 Pointer ← Pointer + 1 1 // wrap back to beginning of table if necessary IF Pointer > 199 1 THEN

Pointer ← 0 1 ENDIF // check if back to original index IF Pointer = Index 1 THEN TableFull ← TRUE ENDIF ENDWHILE IF NOT TableFull 1 THEN

Customer[Pointer] ← NewCustomer 1 ELSE OUTPUT "Error" 1 ENDIF ENDPROCEDURE

9

9608/41 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 4 of 13

Question Answer Marks

2(b)(ii) FUNCTION SearchHashTable(BYVAL SearchID : INTEGER) RETURNS INTEGER // generate hash value Index ← Hash(SearchID) 1 // check each record from index until found or not there WHILE (Customer[Index].CustomerID <> SearchID) 1 AND (Customer[Index].CustomerID > 0) 1

Index ← Index + 1 1 // wrap if necessary IF Index > 199 1 THEN

Index ← 0 1 ENDIF ENDWHILE // has customer ID been found? IF Customer[Index].CustomerID = SearchID 1 THEN RETURN Index 1 ELSE RETURN -1 1 ENDIF ENDFUNCTION

9

2(b)(iii) A record out of place may not be found 1

9608/41 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 5 of 13

Question Answer Marks

3 FUNCTION Find(BYVAL Name : STRING, BYVAL Start : INTEGER, BYVAL Finish : INTEGER) RETURNS INTEGER // base case IF Finish < Start 1 THEN RETURN -1 ELSE

Middle ← (Start + Finish) DIV 2 1 IF NameList[Middle] = Name 1 THEN

RETURN Middle 1 ELSE // general case

IF SearchItem > NameList[Middle] 1 THEN

Find(Name, Middle + 1, Finish) 1 ELSE

Find(Name, Start, Middle - 1) 1 ENDIF ENDIF ENDIF ENDFUNCTION

7

Question Answer Marks

4(a)(i) containment/aggregation 1

4(a)(ii)

1 mark for the two classes (in boxes) and connection with correct end point 1 mark for 0 ..*   0

Max 2

9608/41 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 6 of 13

Question Answer Marks

4(b) mark as follows:

• Class heading and ending • Constructor heading and ending • Parameters in constructor heading • Declaration of (private) attributes : Pointer, Data • Assignment of parameters to Pointer and Data

Python Example

class Node: 1 def __init__(self, D, P): 1 + 1 self.__Data = D 1 self.__Pointer = P 1 return

Example Pascal type Node = class 1 private 1 Data : String; Pointer : Integer; public constructor Create(D : string; P : integer); procedure SetPointer(P : Integer); procedure SetData(D : String); function GetData() : String; ignore function GetPointer() : Integer; end; constructor Node.Create(D : string; P : integer); 1+1 begin Data := D; Pointer := P; 1 end;

Example VB.NET

Class Node 1 Private Data As String Private Pointer As Integer 1 Public Sub New(ByVal D As String, ByVal P As Integer) 1+1 Data = D Pointer = P 1 End Sub End Class

5

4(c)(i) A pointer that doesn’t point to any data/node/address 1

9608/41 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 7 of 13

Question Answer Marks

4(c)(ii) –1 (accept NULL) The array only goes from 0 to 7 // the value is not an array index

2

4(c)(iii) mark as follows: • Class and constructor heading and ending • Declare private attributes (HeadPointer, FreeListPointer, NodeArray) • Initialise HeadPointer to null • Initialise FreeListPointer to 0 • Looping 8 times • Creating empty node in NodeArray • Use .SetPointer method to point each new node to next node • Set last node pointer to null pointer

Python Example

class LinkedList: 1 def __init__(self): 1 self.__HeadPointer = - 1 1 self.__FreeListPointer = 0 1 self.__NodeArray = [] for i in range(8): 1 ThisNode = Node("", (i + 1)) 1 self.__NodeArray.append(ThisNode)

self.__NodeArray[7].SetPointer(- 1) 1 Example Pascal type LinkedList = class 1 private HeadPointer : Integer; FreeList : Integer; NodeArray : Array[0..7] of Node; public constructor Create(); procedure FindInsertionPoint(NewData : string; var PreviousPointer, NextPointer : integer); procedure AddToList(NewData : string); procedure OutputListToConsole(); end; constructor LinkedList.Create(); 1 var i : integer; begin HeadPointer := -1; 1 FreeList := 0; 1 for i := 0 To 7 do 1 NodeArray[i] := Node.Create('', (i + 1)); 1 NodeArray[7].SetPointer(-1); 1 end;

Max 7

9608/41 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 8 of 13

Question Answer Marks

Example VB.NET Class LinkedList 1 Private HeadPointer As Integer Private FreeList As Integer Private NodeArray(7) As Node Public Sub New() 1 HeadPointer = -1 1 FreeList = 0 1 For i = 0 To 7 1 NodeArray(i) = New Node("", (i + 1)) 1 Next NodeArray(7).SetPointer(-1) 1 End Sub End Class

4(c)(iv) • Creating instance of LinkedList assigned to contacts

Python Example contacts = LinkedList()

Pascal Example var contacts : LinkedList; contacts := LinkedList.Create;

VB.NET Example Dim contacts As New LinkedList

1

9608/41 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 9 of 13

Question Answer Marks

4(c)(v) mark as follows: • Start with HeadPointer • Output node data • Loop until null pointer • Following pointer to next node • Use of getter (ie GetData/GetPointer) Python Example def OutputListToConsole(self) : Pointer = self.__HeadPointer 1 while Pointer != -1 : 1 print(self.__NodeArray[Pointer].GetData()) 1+1 Pointer = self.__NodeArray[Pointer].GetPointer() 1 print() return Pascal Example procedure LinkedList.OutputListToConsole(); var Pointer : integer; begin Pointer := HeadPointer; 1 while Pointer <> -1 do 1 begin WriteLn(NodeArray[Pointer].GetData); 1+1 Pointer := NodeArray[Pointer].GetPointer; 1 end; end; VB.NET Example Public Sub OutputListToConsole() Dim Pointer As Integer Pointer = HeadPointer 1 Do While Pointer <> -1 1 Console.WriteLine(NodeArray(Pointer).GetData) 1+1 Pointer = NodeArray(Pointer).GetPointer 1 Loop End Sub

5

9608/41 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 10 of 13

Question Answer Marks

4(c)(vi) mark as follows: • Store free list pointer as NewNodePointer • Store new data item in free node • Adjust free pointer • F list is currently empty • Make the node the first node • Set pointer of this node to Null Pointer • Find insertion point • If previous pointer is Null pointer • Link this node to front of list • Link new node between Previous node and next node

Python Example def AddToList(self, NewData): NewNodePointer = self.__FreeListPointer self.__NodeArray[NewNodePointer].SetData(NewData) self.__FreeListPointer = self.__NodeArray[self.__FreeListPointer].GetPointer() if self.__HeadPointer == -1: self.__HeadPointer = NewNodePointer self.__NodeArray[NewNodePointer ].SetPointer(-1) else: PreviousPointer, NextPointer = self.FindInsertionPoint(NewData) if PreviousPointer == -1 : self.__NodeArray[NewNodePointer ].SetPointer (self.__HeadPointer) self.__HeadPointer = NewNodePointer else: self.__NodeArray[NewNodePointer ].SetPointer(NextPointer) self.__NodeArray[PreviousPointer].SetPointer(NewNodePointer)

Max 6

9608/41 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 11 of 13

Question Answer Marks

Pascal Example procedure LinkedList.AddToList(NewData : string); var NewNodePointer , PreviousPointer, NextPointer : integer; begin // make a copy of free list pointer NewNodePointer := FreeListPointer; // store new data item in free node NodeArray[NewNodePointer].SetData(NewData); // adjust free pointer FreeListPointer := NodeArray[FreeListPointer].GetPointer; // if list is currently empty if HeadPointer = -1 then // make the node the first node begin HeadPointer := NewNodePointer; // set pointer to Null pointer NodeArray[NewNodePointer].SetPointer(-1); end else // find insertion point begin FindInsertionPoint(NewData, PreviousPointer, NextPointer); // if previous pointer is Null pointer if PreviousPointer = -1 then // link node to front of list begin NodeArray[NewNodePointer] .SetPointer(HeadPointer); HeadPointer := NewNodePointer ; end else // link new node between Previous node and next node begin NodeArray[NewNodePointer ] .SetPointer(NextPointer); NodeArray[PreviousPointer] .SetPointer(NewNodePointer); end; end; end;

9608/41 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 12 of 13

Question Answer Marks

VB.NET Example Public Sub AddToList(ByVal NewData As String) Dim NewNodePointer, PreviousPointer, NextPointer As Integer ' make copy of free list pointer NewNodePointer= FreeListPointer ' store new data item in free node NodeArray(NewNodePointer).SetData(NewData) ' adjust free pointer FreeListPointer = NodeArray(FreeListPointer).GetPointer ' if list iscurrently empty If HeadPointer = -1 Then ' make the node the first node HeadPointer = NewNodePointer ' set pointer to Null pointer NodeArray(NewNodePointer).SetPointer(-1) Else ' find insertion point FindInsertionPoint(NewData, PreviousPointer, NextPointer) ' if previous pointer is Null pointer If PreviousPointer = -1 Then ' link to front of list NodeArray(NewNodePointer).SetPointer(HeadPointer) HeadPointer = NewNodePointer Else ' link new node between Previous node and next node NodeArray(NewNodePointer).SetPointer(NextPointer) NodeArray(PreviousPointer).SetPointer(NewNodePointer) End If End If End Sub

9608/41 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 13 of 13

Question Answer Marks

Pseudocode for reference:

PROCEDURE AddToList(NewData) // remember value of free list pointer NewNodePointer ← FreeListPointer // add new data item to free node pointed to by free list NodeArray[NewNodePointer].Data ← NewData // adjust free pointer to point to next free node FreeListPointer ← NodeArray[FreeList].Pointer // is list currently empty? IF HeadPointer = NullPointer THEN // make the node the first node HeadPointer ← NewnodePointer // set pointer of new node to Null pointer NodeArray[NewNodePointer].Pointer ← NullPointer ELSE // find insertion point CALL FindInsertionPoint(NewData, PreviousPPointer, NextPointer) // if previous pointer is Null pointer IF PreviousPointer = NullPointer THEN // link new node to front of list NodeArray[NewNodePointer].Pointer ← HeadPointer HeadPointer ← NewNodePointer ELSE // link new node between previous node and next node NodeArray[NewNodePointer].Pointer ← NextPOinter NodeArray[PreviousPointer].Pointer ← NewNodePointer END IF ENDIF END PROCEDURE

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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;

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

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

® IGCSE is a registered trademark.

This document consists of 13 printed pages.

© UCLES 2017 [Turn over

Cambridge International Examinations Cambridge International Advanced Subsidiary and Advanced Level

COMPUTER SCIENCE 9608/43 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.

9608/43 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 2 of 13

Question Answer Marks

1(a) Label Op

code Operand Comment

START: IN // INPUT character

STO CHAR // store in CHAR 1

LDM #65 // Initialise ACC (ASCII value for 'A' is 65)

1

LOOP: OUT // OUTPUT ACC 1 + 1

CMP CHAR // compare ACC with CHAR 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

CHAR:

8

1(b) START: LDD NUMBER 1

AND MASK // set to zero all bits except sign bit

1

CMP #0 // compare with 0 1

JPN ELSE // if not equal jump to ELSE 1

THEN: LDM #80 // load ACC with 'P' (ASCII value 80) 1

JMP ENDIF

ELSE: LDM #78 // load ACC with 'N' (ASCII value 78)

ENDIF: OUT //output character 1

END

NUMBER: B00000101 // integer to be tested

MASK: B10000000 // show value of mask in binary here

1

7

9608/43 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 3 of 13

Question Answer Marks

2(a) 1 mark for the declaration of the array. 1 mark for assigning a 0 to Customer ID (CustomerID ← 0) 1 mark for getting the correct record (Customer[x].) 1 mark for setting up a loop to go from 0 to 199

DECLARE Customer : ARRAY[0 : 199] OF CustomerRecord 1

FOR x ← 0 TO 199 1

Customer[x].CustomerID ← 0 1+1

ENDFOR

4

2(b)(i) PROCEDURE InsertRecord(BYVAL NewCustomer : CustomerRecord) TableFull ← FALSE // generate hash value Index ← Hash(NewCustomer.CustomerID) 1 Pointer ← Index // take a copy of index // find a free table element WHILE Customer[Pointer].CustomerID > 0 1 Pointer ← Pointer + 1 1 // wrap back to beginning of table if necessary IF Pointer > 199 1 THEN

Pointer ← 0 1 ENDIF // check if back to original index IF Pointer = Index 1 THEN TableFull ← TRUE ENDIF ENDWHILE IF NOT TableFull 1 THEN

Customer[Pointer] ← NewCustomer 1 ELSE OUTPUT "Error" 1 ENDIF ENDPROCEDURE

9

9608/43 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 4 of 13

Question Answer Marks

2(b)(ii) FUNCTION SearchHashTable(BYVAL SearchID : INTEGER) RETURNS INTEGER // generate hash value Index ← Hash(SearchID) 1 // check each record from index until found or not there WHILE (Customer[Index].CustomerID <> SearchID) 1 AND (Customer[Index].CustomerID > 0) 1

Index ← Index + 1 1 // wrap if necessary IF Index > 199 1 THEN

Index ← 0 1 ENDIF ENDWHILE // has customer ID been found? IF Customer[Index].CustomerID = SearchID 1 THEN RETURN Index 1 ELSE RETURN -1 1 ENDIF ENDFUNCTION

9

2(b)(iii) A record out of place may not be found 1

9608/43 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 5 of 13

Question Answer Marks

3 FUNCTION Find(BYVAL Name : STRING, BYVAL Start : INTEGER, BYVAL Finish : INTEGER) RETURNS INTEGER // base case IF Finish < Start 1 THEN RETURN -1 ELSE

Middle ← (Start + Finish) DIV 2 1 IF NameList[Middle] = Name 1 THEN

RETURN Middle 1 ELSE // general case

IF SearchItem > NameList[Middle] 1 THEN

Find(Name, Middle + 1, Finish) 1 ELSE

Find(Name, Start, Middle - 1) 1 ENDIF ENDIF ENDIF ENDFUNCTION

7

Question Answer Marks

4(a)(i) containment/aggregation 1

4(a)(ii)

1 mark for the two classes (in boxes) and connection with correct end point 1 mark for 0 ..*   0

Max 2

9608/43 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 6 of 13

Question Answer Marks

4(b) mark as follows:

• Class heading and ending • Constructor heading and ending • Parameters in constructor heading • Declaration of (private) attributes : Pointer, Data • Assignment of parameters to Pointer and Data

Python Example

class Node: 1 def __init__(self, D, P): 1 + 1 self.__Data = D 1 self.__Pointer = P 1 return

Example Pascal type Node = class 1 private 1 Data : String; Pointer : Integer; public constructor Create(D : string; P : integer); procedure SetPointer(P : Integer); procedure SetData(D : String); function GetData() : String; ignore function GetPointer() : Integer; end; constructor Node.Create(D : string; P : integer); 1+1 begin Data := D; Pointer := P; 1 end;

Example VB.NET

Class Node 1 Private Data As String Private Pointer As Integer 1 Public Sub New(ByVal D As String, ByVal P As Integer) 1+1 Data = D Pointer = P 1 End Sub End Class

5

4(c)(i) A pointer that doesn’t point to any data/node/address 1

9608/43 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 7 of 13

Question Answer Marks

4(c)(ii) –1 (accept NULL) The array only goes from 0 to 7 // the value is not an array index

2

4(c)(iii) mark as follows: • Class and constructor heading and ending • Declare private attributes (HeadPointer, FreeListPointer, NodeArray) • Initialise HeadPointer to null • Initialise FreeListPointer to 0 • Looping 8 times • Creating empty node in NodeArray • Use .SetPointer method to point each new node to next node • Set last node pointer to null pointer

Python Example

class LinkedList: 1 def __init__(self): 1 self.__HeadPointer = - 1 1 self.__FreeListPointer = 0 1 self.__NodeArray = [] for i in range(8): 1 ThisNode = Node("", (i + 1)) 1 self.__NodeArray.append(ThisNode)

self.__NodeArray[7].SetPointer(- 1) 1 Example Pascal type LinkedList = class 1 private HeadPointer : Integer; FreeList : Integer; NodeArray : Array[0..7] of Node; public constructor Create(); procedure FindInsertionPoint(NewData : string; var PreviousPointer, NextPointer : integer); procedure AddToList(NewData : string); procedure OutputListToConsole(); end; constructor LinkedList.Create(); 1 var i : integer; begin HeadPointer := -1; 1 FreeList := 0; 1 for i := 0 To 7 do 1 NodeArray[i] := Node.Create('', (i + 1)); 1 NodeArray[7].SetPointer(-1); 1 end;

Max 7

9608/43 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 8 of 13

Question Answer Marks

Example VB.NET Class LinkedList 1 Private HeadPointer As Integer Private FreeList As Integer Private NodeArray(7) As Node Public Sub New() 1 HeadPointer = -1 1 FreeList = 0 1 For i = 0 To 7 1 NodeArray(i) = New Node("", (i + 1)) 1 Next NodeArray(7).SetPointer(-1) 1 End Sub End Class

4(c)(iv) • Creating instance of LinkedList assigned to contacts

Python Example contacts = LinkedList()

Pascal Example var contacts : LinkedList; contacts := LinkedList.Create;

VB.NET Example Dim contacts As New LinkedList

1

9608/43 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 9 of 13

Question Answer Marks

4(c)(v) mark as follows: • Start with HeadPointer • Output node data • Loop until null pointer • Following pointer to next node • Use of getter (ie GetData/GetPointer) Python Example def OutputListToConsole(self) : Pointer = self.__HeadPointer 1 while Pointer != -1 : 1 print(self.__NodeArray[Pointer].GetData()) 1+1 Pointer = self.__NodeArray[Pointer].GetPointer() 1 print() return Pascal Example procedure LinkedList.OutputListToConsole(); var Pointer : integer; begin Pointer := HeadPointer; 1 while Pointer <> -1 do 1 begin WriteLn(NodeArray[Pointer].GetData); 1+1 Pointer := NodeArray[Pointer].GetPointer; 1 end; end; VB.NET Example Public Sub OutputListToConsole() Dim Pointer As Integer Pointer = HeadPointer 1 Do While Pointer <> -1 1 Console.WriteLine(NodeArray(Pointer).GetData) 1+1 Pointer = NodeArray(Pointer).GetPointer 1 Loop End Sub

5

9608/43 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 10 of 13

Question Answer Marks

4(c)(vi) mark as follows: • Store free list pointer as NewNodePointer • Store new data item in free node • Adjust free pointer • F list is currently empty • Make the node the first node • Set pointer of this node to Null Pointer • Find insertion point • If previous pointer is Null pointer • Link this node to front of list • Link new node between Previous node and next node

Python Example def AddToList(self, NewData): NewNodePointer = self.__FreeListPointer self.__NodeArray[NewNodePointer].SetData(NewData) self.__FreeListPointer = self.__NodeArray[self.__FreeListPointer].GetPointer() if self.__HeadPointer == -1: self.__HeadPointer = NewNodePointer self.__NodeArray[NewNodePointer ].SetPointer(-1) else: PreviousPointer, NextPointer = self.FindInsertionPoint(NewData) if PreviousPointer == -1 : self.__NodeArray[NewNodePointer ].SetPointer (self.__HeadPointer) self.__HeadPointer = NewNodePointer else: self.__NodeArray[NewNodePointer ].SetPointer(NextPointer) self.__NodeArray[PreviousPointer].SetPointer(NewNodePointer)

Max 6

9608/43 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 11 of 13

Question Answer Marks

Pascal Example procedure LinkedList.AddToList(NewData : string); var NewNodePointer , PreviousPointer, NextPointer : integer; begin // make a copy of free list pointer NewNodePointer := FreeListPointer; // store new data item in free node NodeArray[NewNodePointer].SetData(NewData); // adjust free pointer FreeListPointer := NodeArray[FreeListPointer].GetPointer; // if list is currently empty if HeadPointer = -1 then // make the node the first node begin HeadPointer := NewNodePointer; // set pointer to Null pointer NodeArray[NewNodePointer].SetPointer(-1); end else // find insertion point begin FindInsertionPoint(NewData, PreviousPointer, NextPointer); // if previous pointer is Null pointer if PreviousPointer = -1 then // link node to front of list begin NodeArray[NewNodePointer] .SetPointer(HeadPointer); HeadPointer := NewNodePointer ; end else // link new node between Previous node and next node begin NodeArray[NewNodePointer ] .SetPointer(NextPointer); NodeArray[PreviousPointer] .SetPointer(NewNodePointer); end; end; end;

9608/43 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 12 of 13

Question Answer Marks

VB.NET Example Public Sub AddToList(ByVal NewData As String) Dim NewNodePointer, PreviousPointer, NextPointer As Integer ' make copy of free list pointer NewNodePointer= FreeListPointer ' store new data item in free node NodeArray(NewNodePointer).SetData(NewData) ' adjust free pointer FreeListPointer = NodeArray(FreeListPointer).GetPointer ' if list iscurrently empty If HeadPointer = -1 Then ' make the node the first node HeadPointer = NewNodePointer ' set pointer to Null pointer NodeArray(NewNodePointer).SetPointer(-1) Else ' find insertion point FindInsertionPoint(NewData, PreviousPointer, NextPointer) ' if previous pointer is Null pointer If PreviousPointer = -1 Then ' link to front of list NodeArray(NewNodePointer).SetPointer(HeadPointer) HeadPointer = NewNodePointer Else ' link new node between Previous node and next node NodeArray(NewNodePointer).SetPointer(NextPointer) NodeArray(PreviousPointer).SetPointer(NewNodePointer) End If End If End Sub

9608/43 Cambridge International AS/A Level – Mark Scheme PUBLISHED

May/June 2017

© UCLES 2017 Page 13 of 13

Question Answer Marks

Pseudocode for reference:

PROCEDURE AddToList(NewData) // remember value of free list pointer NewNodePointer ← FreeListPointer // add new data item to free node pointed to by free list NodeArray[NewNodePointer].Data ← NewData // adjust free pointer to point to next free node FreeListPointer ← NodeArray[FreeList].Pointer // is list currently empty? IF HeadPointer = NullPointer THEN // make the node the first node HeadPointer ← NewnodePointer // set pointer of new node to Null pointer NodeArray[NewNodePointer].Pointer ← NullPointer ELSE // find insertion point CALL FindInsertionPoint(NewData, PreviousPPointer, NextPointer) // if previous pointer is Null pointer IF PreviousPointer = NullPointer THEN // link new node to front of list NodeArray[NewNodePointer].Pointer ← HeadPointer HeadPointer ← NewNodePointer ELSE // link new node between previous node and next node NodeArray[NewNodePointer].Pointer ← NextPOinter NodeArray[PreviousPointer].Pointer ← NewNodePointer END IF ENDIF END PROCEDURE