Beruflich Dokumente
Kultur Dokumente
A- Level
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
DC (FD) 110069
© UCLES 2015 [Turn over
3
2
1 The following syntax diagrams, for a particular programming language, show the syntax of:
• an assignment statement
• a variable
• a letter
• an operator
Assignment statement
Variable = Variable Operator Variable ;
Variable
Letter Letter Letter
Letter Operator
a +
b –
d ÷
(i) a = b + c
Reason ..............................................................................................................................
.......................................................................................................................................[1]
(ii) a = b – 2;
Reason ..............................................................................................................................
.......................................................................................................................................[1]
(iii) a = dd * cce;
Reason ..............................................................................................................................
.......................................................................................................................................[1]
(b) Write the Backus-Naur Form (BNF) for the syntax diagrams shown on the opposite page.
<assignmentstatement> ::=
...................................................................................................................................................
<variable> ::=
...................................................................................................................................................
<letter> ::=
...................................................................................................................................................
<operator> ::=
...............................................................................................................................................[6]
(c) Rewrite the BNF rule for a variable so that it can be any number of letters.
<variable> ::=
...............................................................................................................................................[2]
(d) Programmers working for a software development company use both interpreters and
compilers.
...........................................................................................................................................
.......................................................................................................................................[1]
Give a reason why this helps to protect the security of the source code.
...........................................................................................................................................
.......................................................................................................................................[1]
2 The incomplete table below shows descriptions and terms relating to malware.
Description Term
..................................................................................................
..................................................................................................
C .................................................................................................. Pharming
..................................................................................................
..................................................................................................
..................................................................................................
..................................................................................................
D .................................................................................................. Phishing
..................................................................................................
..................................................................................................
[4]
Problem ....................................................................................................................................
...................................................................................................................................................
Solution .....................................................................................................................................
...............................................................................................................................................[2]
Encryption .................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[2]
(i) State what should be part of the download to provide proof that the software is authentic.
.......................................................................................................................................[1]
(ii) Describe the process for ensuring that the software is both authentic and has not been
altered.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[4]
3 (a) A particular programming language allows the programmer to define their own data types.
TYPE ThisDate
DECLARE ThisDay : (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31)
DECLARE ThisMonth : (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug,
Sep, Oct, Nov, Dec)
DECLARE ThisYear : INTEGER
ENDTYPE
(i) Name the non-composite data type used in the ThisDay and ThisMonth declarations.
.......................................................................................................................................[1]
.......................................................................................................................................[1]
.......................................................................................................................................[1]
(b) Annual rainfall data from a number of locations are to be processed in a program.
• location name
• height above sea level (to the nearest metre)
• total rainfall for each month of the year (centimetres to 1 decimal place)
A variable of this type can be used to store all the data for one particular location.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[5]
(ii) The programmer decides to store all the data in a file. Initially, data from 27 locations will
be stored. More rainfall locations will be added over time and will never exceed 100.
The programmer has to choose between two types of file organisation. The two types are
serial and sequential.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
4 (a) (i) Complete the truth table for this logic circuit:
A
X
Working space
A B X
0 0
0 1
1 0
1 1
[1]
Working space
A B X
0 0
0 1
1 0
1 1
[1]
(b) A student decides to write an equation for X to represent the full behaviour of each logic
circuit.
(i) Write the Boolean expression that will complete the required equation for X for each
circuit:
Circuit 1: X = ......................................................................................................................
Circuit 2: X = ..................................................................................................................[2]
(ii) Write the De Morgan’s Law which is shown by your answers to part (a) and part (b)(i).
.......................................................................................................................................[1]
(c) Write the Boolean algebraic expression corresponding to the following logic circuit:
A
B
...............................................................................................................................................[3]
(d) Using De Morgan’s laws and Boolean algebra, simplify your answer to part (c).
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[3]
5 A gardener grows vegetables in a greenhouse. For the vegetables to grow well, the temperature
needs to always be within a particular range.
The gardener is not sure about the actual temperatures in the greenhouse during the growing
season. The gardener installs some equipment. This records the temperature every hour during
the growing season.
...............................................................................................................................................[1]
(b) Identify three items of hardware that would be needed to acquire and record the temperature
data. Justify your choice for each.
Item 1 ........................................................................................................................................
Justification ...............................................................................................................................
...................................................................................................................................................
Item 2 ........................................................................................................................................
Justification ...............................................................................................................................
...................................................................................................................................................
Item 3 ........................................................................................................................................
Justification ................................................................................................................................
...............................................................................................................................................[6]
(c) The equipment records temperatures in the greenhouse. It does this for seven locations.
Each recording is stored as two successive bytes. The format is shown below:
7 6 5 4 3 2 1 0
Byte 1 Byte 2
The location is indicated by the setting of one of the seven bits in byte 1. For example,
location 4 is indicated by setting bit 4.
7 6 5 4 3 2 1 0
0 0 1 0 0 0 0 1 0 0 0 1 1 0 0 0
Byte 1 Byte 2
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
Complete the boxes below to show the two bytes for this recording. The reading has not
yet been processed.
7 6 5 4 3 2 1 0
Byte 1 Byte 2
[2]
(d) (i) The accumulator is loaded with the value of byte 1 from location 106.
Write the assembly language instruction to check whether the reading in byte 2 came
from location 4.
.......................................................................................................................................[4]
(ii) Write the assembly language instruction to set the flag (bit 0) of the byte contained in the
accumulator to 1.
.......................................................................................................................................[2]
[4]
(b) Downloading a file can use the client-server model. Alternatively, a file can be downloaded
using the BitTorrent protocol.
...............................................................................................................................................[1]
(c) For the BitTorrent protocol, explain the function of each of the following:
...........................................................................................................................................
.......................................................................................................................................[2]
...........................................................................................................................................
.......................................................................................................................................[2]
...........................................................................................................................................
.......................................................................................................................................[2]
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.
This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of
the examination. It shows the basis on which Examiners were instructed to award marks. It does not
indicate the details of the discussions that took place at an Examiners’ meeting before marking began,
which would have considered the acceptability of alternative answers.
Mark schemes should be read in conjunction with the question paper and the Principal Examiner
Report for Teachers.
Cambridge will not enter into discussions about these mark schemes.
Cambridge is publishing the mark schemes for the May/June 2015 series for most
Cambridge IGCSE®, Cambridge International A and AS Level components and some
Cambridge O Level components.
1
<letter> ::= a|b|c|d
<operator> :: =+|-|*|÷
(ii) compiler produces executable version – not readable / no need for source
code 1
// difficult to reverse-engineer
Total: 13
2 (a) • Spam 1
• Worm 1
Pharming
redirect website to fake website // domain name server compromised
// proxy server compromised 1
Phishing 1
through email attempt to obtain somebody’s confidential data / install
malware
(b) Spam
• user’s inbox is filled by large amount of unwanted email 1
• user / email server employs filtering software that can divert / delete 1
spam email or
Worm 1
• could corrupt user’s computer // delete data // consume bandwidth
• run anti-virus software in the background // not connect to the Internet 1
// keep OS up-to-date
Total: 13
(ii) record 1
[max 2]
Total: 10
4 (a) (i)
Circuit 1
A B X
0 0 1
0 1 1
1 0 1
1 1 0 1
(ii)
Circuit 2
A B X
0 0 1
0 1 1
1 0 1
1 1 0 1
(ii) A.B ≡ A + B 1
(c) ( A + B).B
Mark as follows:
( A + B) 1
.B 1
bar over whole expression 1
(d) ( A + B).B
1
= ( A + B) + B
1
= ( A + B) + B
1
= A + ( B + B)
= A +1 1
=1 1
Total: 11
Total: 17
6 (a)
Description Protocol used
(b) peer-to-peer 1
Total: 11
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
DC (ST/SW) 95542/2
© UCLES 2015 [Turn over
20
2
1 The following syntax diagrams, for a particular programming language, show the syntax of:
• an assignment statement
• a variable
• a number
• a letter
• a digit
• an operator
Assignment statement
Variable := Variable Operator Number
Variable
Letter Number
Number
Digit
Letter
A
Digit
1
Operator
+
(i) A2 = B3 + 123
Reason ..............................................................................................................................
.......................................................................................................................................[1]
(ii) B3 := B3 – 203
Reason ..............................................................................................................................
.......................................................................................................................................[1]
(iii) A2414 := A3 * B
Reason ..............................................................................................................................
.......................................................................................................................................[1]
(b) Complete the Backus-Naur Form (BNF) for the syntax diagrams shown on the opposite page.
<assignmentstatement> ::=
...................................................................................................................................................
<variable> ::=
...................................................................................................................................................
<number> ::=
...................................................................................................................................................
<letter> ::= A | B | C
<digit> ::=
...................................................................................................................................................
<operator> ::=
...................................................................................................................................................
[6]
(c) A company develops software. It provides virtual machines for its software developers. The
company has a large number of clients who use a wide range of hardware and software.
(i) Explain the term virtual machine. Ensure that your answer includes the terms hardware
and software.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
...........................................................................................................................................
.......................................................................................................................................[1]
...........................................................................................................................................
.......................................................................................................................................[1]
2 (a) Four descriptions and three types of local area network (LAN) are shown below.
Draw a line to connect each description to the type of LAN it applies to.
...........................................................................................................................................
.......................................................................................................................................[2]
...........................................................................................................................................
.......................................................................................................................................[2]
...........................................................................................................................................
.......................................................................................................................................[2]
3 The incomplete table below shows descriptions and terms relating to malware.
Description Term
........................................................................................
C ........................................................................................ Worm
........................................................................................
........................................................................................
D ........................................................................................ Spam
........................................................................................
[4]
Term .....................
Problem ....................................................................................................................................
...................................................................................................................................................
Solution .....................................................................................................................................
...............................................................................................................................................[2]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[2]
(d) Bill, a manager of a company, sent an email with very sensitive information to a work
colleague, Alison. However, Bill also accidentally sent it to everybody in the company.
Describe the method used that ensured only Alison was able to read the original contents of
the email.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[4]
4 (a) A particular programming language allows the programmer to define their own data types.
TYPE ThisAddress
DECLARE ThisHouseNo : INTEGER
DECLARE ThisStreet : STRING
DECLARE ThisTown : STRING
ENDTYPE
(i) Write the statement that assigns the house number 34 to HomeAddress.
.......................................................................................................................................[1]
Rewrite one line from the definition for each of the following changes.
DECLARE ...........................................................................................................................
The possible towns are limited to: Brightown, Arunde and Shoram.
DECLARE .......................................................................................................................[2]
(b) Temperature data from a number of weather stations are to be processed by a program.
• average temperature (to the nearest whole number) for each year from 2001 to 2015
inclusive
A programmer designs a composite data type WeatherStation. A variable of this type can
be used to store all the data for one particular station.
(i) Write the definition for the user-defined data type WeatherStation.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[5]
(ii) The programmer decides to store all the data in a file. The number of weather stations
could grow to reach 20000, but not all stations will be present at first.
Describe three steps which show how a new weather station record is added to the file.
1 ........................................................................................................................................
...........................................................................................................................................
2 ........................................................................................................................................
...........................................................................................................................................
3 ........................................................................................................................................
.......................................................................................................................................[3]
5 (a) (i) Complete the truth table for this logic circuit:
A
X
Working space
A B X
0 0
0 1
1 0
1 1
[1]
Working space
A B X
0 0
0 1
1 0
1 1
[1]
(b) A student decides to write an equation for X to represent the full behaviour of each logic
circuit.
(i) Write the Boolean expression that will complete the required equation for X for each
circuit:
Circuit 1: X = ......................................................................................................................
Circuit 2: X = ..................................................................................................................[2]
(ii) Write the De Morgan’s Law which is shown by your answers to part (a) and part (b)(i).
.......................................................................................................................................[1]
(c) Write the Boolean algebraic expression corresponding to the following logic circuit:
A
B
...............................................................................................................................................[3]
(d) Using De Morgan’s laws and Boolean algebra, simplify your answer to part (c).
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[3]
6 A company grows vegetables in a number of large greenhouses. For the vegetables to grow well,
the temperature, light level and soil moisture need to always be within certain ranges.
The company installs a computerised system to keep these three growing conditions within the
best ranges. Sensors are used for collecting data about the temperature, light level, and moisture
content of the soil.
...............................................................................................................................................[1]
(b) Give three items of hardware that would be needed for this system. Justify your choice.
Do not include sensors in your answer.
Item 1 ........................................................................................................................................
Justification ...............................................................................................................................
...................................................................................................................................................
Item 2 ........................................................................................................................................
Justification ...............................................................................................................................
...................................................................................................................................................
Item 3 ........................................................................................................................................
Justification ...............................................................................................................................
...............................................................................................................................................[6]
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
(ii) When the system was designed, various parameters for temperature were set.
...........................................................................................................................................
.......................................................................................................................................[1]
(iii) Explain how this parameter value is used by the feedback system.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
• A flag is set to indicate whether its associated sensor reading is waiting to be processed.
• More than one sensor reading may be waiting to be processed at any particular moment.
• Data received from the sensors is stored in a block of eight consecutive bytes (addresses
201–208).
• The data from sensor 1 is at address 201, the data from sensor 2 is at address 202, and
so on.
Sensor number
1 2 3 4 5 6 7 8
150 0 1 0 0 0 1 0 1
201 0 0 0 0 0 0 0 0
202 0 0 0 0 0 1 0 0
203 0 0 0 0 0 0 0 0
204 0 0 0 1 0 0 0 0
205 0 0 0 0 0 0 1 0
206 0 0 0 1 0 1 0 0
207 0 0 0 1 0 0 1 0
208 0 0 0 1 0 0 1 0
...........................................................................................................................................
.......................................................................................................................................[2]
(ii) The accumulator is loaded with the data from location 150.
Write the assembly language instruction to check whether there is a value waiting to be
processed for sensor 6.
.......................................................................................................................................[3]
This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of
the examination. It shows the basis on which Examiners were instructed to award marks. It does not
indicate the details of the discussions that took place at an Examiners’ meeting before marking began,
which would have considered the acceptability of alternative answers.
Mark schemes should be read in conjunction with the question paper and the Principal Examiner
Report for Teachers.
Cambridge will not enter into discussions about these mark schemes.
Cambridge is publishing the mark schemes for the May/June 2015 series for most
Cambridge IGCSE®, Cambridge International A and AS Level components and some
Cambridge O Level components.
(ii) e.g.
no need to acquire client hardware for testing /
reduces set-up time for test system /
common development system for all developers 1
(iii) e.g.
software emulation runs slower than real hardware /
not possible to emulate some hardware 1
Total: 13
2 (a)
Description Type of LAN
Total: 10
3 (a) A Phishing 1
B Virus 1
C a standalone piece of software which can reproduce itself automatically 1
D sending unsolicited emails to a distribution list 1
Total: 12
Total: 11
5 (a) (i)
Circuit 1
A B X 1
0 0 1
0 1 0
1 0 0
1 1 0
(ii)
Circuit 2
A B X 1
0 0 1
0 1 0
1 0 0
1 1 0
(ii) 1
A+ B ≡ A.B
(c)
( A.B ) + B
mark as :
( A.B ) 1
+B 1
bar over whole expression 1
(d)
( A.B ) + B
1
= ( A.B ) . B
1
= ( A.B ).B
1
= A.( B.B )
= A.0 1
=0 1
max 3
allow f.t. from (c)
Total: 11
(c) (i) output of system (alter temperature / light level / soil moisture)
affects input from sensors
continuous 3
(ii) min / max / ideal / mean / extreme temperature // sampling rate // tolerance 1
interval
Total: 18
Candidates should use this material in preparation for the examination. Candidates should attempt the
practical programming tasks using their chosen high-level, procedural programming language.
DC (AC/SW) 95229/3
© UCLES 2015 [Turn over
39
2
This material is intended to be read by teachers and candidates prior to the June 2015 examination for
9608 Paper 4.
Reminders
The syllabus states:
• there will be questions on the examination paper which do not relate to this pre-release material
• you must choose a high-level programming language from this list:
• Visual Basic (Console Mode)
• Python
• Pascal / Delphi (Console Mode)
The practical skills covered in Paper 2 are a precursor to those required in Paper 4. It is therefore
recommended that the high-level programming language chosen for this paper is the same as that for
Paper 2. This allows for sufficient expertise to be acquired with the opportunity for extensive practice.
TASK 1
A linked list Abstract Data Type (ADT) has these associated operations:
The linked list ADT consists of a linked list of nodes. Each node consists of data and a pointer to the
next node.
TASK 1.1
Consider the use of a linked list to store names in alphabetical order.
CreateLinkedList
AddName("Nabila")
AddName("Jack")
AddName("Kerrie") Key focus: Conceptual
AddName("Sara") diagrams of linked lists
RemoveName("Kerrie")
AddName("Zac")
Add appropriate labels to the diagram to show the final state of the linked list. Use the space on the left
as a workspace. Show your final answer in the node shapes on the right:
TASK 1.2
The linked list is to be implemented as an array of records, where each record represents a node.
The CreateLinkedList operation links all nodes to form the free list and initialises the HeadPointer
and FreePointer.
Complete the diagram to show the values of all pointers after the CreateLinkedList operation has
been carried out.
NameList
HeadPointer Name Pointer
[1]
[2]
[3]
[4]
[5]
FreePointer [6]
[49]
[50]
TASK 1.3
Complete the diagram to show the values of all pointers after the following operations have been
carried out:
AddName("Nabila")
AddName("Jack")
AddName("Kerrie")
AddName("Sara")
RemoveName("Kerrie")
AddName("Zac")
NameList
HeadPointer Name Pointer
[1]
[2]
[3]
[4]
[5]
FreePointer [6]
[49]
[50]
TASK 1.4
Complete the identifier table for the pseudocode given below.
01 PROCEDURE AddName(NewName)
02 // New name placed in node at head of free list
03 NameList[FreePointer].Name ←
NewName
04 NewNodePointer ←
FreePointer
05 FreePointer ←
NameList[FreePointer].Pointer
06
07 // initialise current pointer to start of list
08 CurrentPointer ←
HeadPointer
09
10 // check that it is not the special case of adding to empty list
11 IF HeadPointer > 0
12 // loop to locate position of new name
13 // saves current pointer and then updates current pointer
14 WHILE NameList[CurrentPointer].Name < NewName
15 PreviousPointer ←
CurrentPointer
16 CurrentPointer ←
NameList[CurrentPointer].Pointer
17 ENDWHILE
18 ENDIF
19
20 // check to see whether new name is first in linked list
21 // if first item then place item at head of list
22 // if not first item then adjust pointers to place it in correct
23 // position in list
24 IF CurrentPointer = HeadPointer
25 THEN
26 NameList[NewNodePointer].Pointer HeadPointer ←
27 HeadPointer ←
NewNodePointer
28 ELSE
29 NameList[NewNodePointer].Pointer ←
NameList[PreviousPointer].Pointer
30 NameList[PreviousPointer].Pointer ←
NewNodePointer
31 ENDIF
32 ENDPROCEDURE
TASK 1.5
Write program code for the pseudocode given in Task 1.4.
TASK 1.6
The structured English algorithm for the operation to remove a name from the linked list is as follows:
TASK 1.6.1
Write the algorithm, as a procedure in pseudocode, from the structured English given above.
TASK 1.6.2
Write program code from your pseudocode design.
TASK 1.6.3
Test your program code for creating a linked list, adding and removing names, using the data given in
Task 1.3.
Design pseudocode and write program code for these data structures.
TASK 2
The unique registration and the engine size (in litres, to the nearest 0.1 of a litre) are stored for all
vehicles.
Data stored about cars also include the hire charge per day (in $) and the number of passengers
allowed.
Data stored about trucks also include the hire charge per hour (in $) and the maximum payload (in kg).
Object-oriented software is to be written to process data about vehicles hired, including calculating the
hire fee.
The superclass (also known as base class or parent class) Vehicle is designed.
Two subclasses (also known as derived classes or child classes) have been identified:
• Car
Key focus: Object-oriented programming
• Truck
TASK 2.1
Complete the inheritance diagram.
TASK 2.2
Complete the class diagram showing the appropriate properties and methods.
........................................................................
........................................................................
........................................................................
........................................................................
........................................................................
........................................................................
........................................................................
....................................................................... .......................................................................
....................................................................... .......................................................................
....................................................................... .......................................................................
....................................................................... .......................................................................
Constructor() .......................................................................
....................................................................... .......................................................................
....................................................................... .......................................................................
....................................................................... .......................................................................
Note: a constructor is a method that creates a new instance of a class and initialises it.
TASK 2.3
Write program code for the class definitions. Make use of polymorphism and inheritance where
appropriate.
TASK 2.4
Write program code to create a new instance of Car.
TASK 3
An intruder detection system is inactive when the power is switched off. The system is activated when
the power is switched on. When the system senses an intruder the alarm bell rings. A reset button is
pressed to turn the alarm bell off and return the system to the active state.
The transition from one state to another is as shown in the state transition table below.
..............................
start
.............................. ..............................
..............................
..............................
.............................. ..............................
..............................
Candidates should use this material in preparation for the examination. Candidates should attempt the
practical programming tasks using their chosen high-level, procedural programming language.
DC (RW) 107191
© UCLES 2015 [Turn over
49
2
This material is intended to be read by teachers and candidates prior to the June 2015 examination for
9608 Paper 4.
Reminders
The syllabus states:
• there will be questions on the examination paper which do not relate to this pre-release material
• you must choose a high-level programming language from this list:
• Visual Basic (Console Mode)
• Python
• Pascal / Delphi (Console Mode)
The practical skills covered in Paper 2 are a precursor to those required in Paper 4. It is therefore
recommended that the high-level programming language chosen for this paper is the same as that for
Paper 2. This allows for sufficient expertise to be acquired with the opportunity for extensive practice.
TASK 1
A linked list Abstract Data Type (ADT) has these associated operations:
The linked list ADT consists of a linked list of nodes. Each node consists of data and a pointer to the
next node.
TASK 1.1
Consider the use of a linked list to store names in alphabetical order.
CreateLinkedList
AddName("Nabila")
AddName("Jack")
AddName("Kerrie") Key focus: Conceptual
AddName("Sara") diagrams of linked lists
RemoveName("Kerrie")
AddName("Zac")
Add appropriate labels to the diagram to show the final state of the linked list. Use the space on the left
as a workspace. Show your final answer in the node shapes on the right:
TASK 1.2
The linked list is to be implemented as an array of records, where each record represents a node.
The CreateLinkedList operation links all nodes to form the free list and initialises the HeadPointer
and FreePointer.
Complete the diagram to show the values of all pointers after the CreateLinkedList operation has
been carried out.
NameList
HeadPointer Name Pointer
[1]
[2]
[3]
[4]
[5]
FreePointer [6]
[49]
[50]
TASK 1.3
Complete the diagram to show the values of all pointers after the following operations have been
carried out:
AddName("Nabila")
AddName("Jack")
AddName("Kerrie")
AddName("Sara")
RemoveName("Kerrie")
AddName("Zac")
NameList
HeadPointer Name Pointer
[1]
[2]
[3]
[4]
[5]
FreePointer [6]
[49]
[50]
TASK 1.4
Complete the identifier table for the pseudocode given below.
01 PROCEDURE AddName(NewName)
02 // New name placed in node at head of free list
03 NameList[FreePointer].Name ←
NewName
04 NewNodePointer ←
FreePointer
05 FreePointer ←
NameList[FreePointer].Pointer
06
07 // initialise current pointer to start of list
08 CurrentPointer ←
HeadPointer
09
10 // check that it is not the special case of adding to empty list
11 IF HeadPointer > 0
12 // loop to locate position of new name
13 // saves current pointer and then updates current pointer
14 WHILE NameList[CurrentPointer].Name < NewName
15 PreviousPointer ←
CurrentPointer
16 CurrentPointer ←
NameList[CurrentPointer].Pointer
17 ENDWHILE
18 ENDIF
19
20 // check to see whether new name is first in linked list
21 // if first item then place item at head of list
22 // if not first item then adjust pointers to place it in correct
23 // position in list
24 IF CurrentPointer = HeadPointer
25 THEN
26 NameList[NewNodePointer].Pointer HeadPointer ←
27 HeadPointer ←
NewNodePointer
28 ELSE
29 NameList[NewNodePointer].Pointer ←
NameList[PreviousPointer].Pointer
30 NameList[PreviousPointer].Pointer ←
NewNodePointer
31 ENDIF
32 ENDPROCEDURE
TASK 1.5
Write program code for the pseudocode given in Task 1.4.
TASK 1.6
The structured English algorithm for the operation to remove a name from the linked list is as follows:
TASK 1.6.1
Write the algorithm, as a procedure in pseudocode, from the structured English given above.
TASK 1.6.2
Write program code from your pseudocode design.
TASK 1.6.3
Test your program code for creating a linked list, adding and removing names, using the data given in
Task 1.3.
Design pseudocode and write program code for these data structures.
TASK 2
The unique registration and the engine size (in litres, to the nearest 0.1 of a litre) are stored for all
vehicles.
Data stored about cars also include the hire charge per day (in $) and the number of passengers
allowed.
Data stored about trucks also include the hire charge per hour (in $) and the maximum payload (in kg).
Object-oriented software is to be written to process data about vehicles hired, including calculating the
hire fee.
The superclass (also known as base class or parent class) Vehicle is designed.
Two subclasses (also known as derived classes or child classes) have been identified:
• Car
Key focus: Object-oriented programming
• Truck
TASK 2.1
Complete the inheritance diagram.
TASK 2.2
Complete the class diagram showing the appropriate properties and methods.
........................................................................
........................................................................
........................................................................
........................................................................
........................................................................
........................................................................
........................................................................
....................................................................... .......................................................................
....................................................................... .......................................................................
....................................................................... .......................................................................
....................................................................... .......................................................................
Constructor() .......................................................................
....................................................................... .......................................................................
....................................................................... .......................................................................
....................................................................... .......................................................................
Note: a constructor is a method that creates a new instance of a class and initialises it.
TASK 2.3
Write program code for the class definitions. Make use of polymorphism and inheritance where
appropriate.
TASK 2.4
Write program code to create a new instance of Car.
TASK 3
An intruder detection system is inactive when the power is switched off. The system is activated when
the power is switched on. When the system senses an intruder the alarm bell rings. A reset button is
pressed to turn the alarm bell off and return the system to the active state.
The transition from one state to another is as shown in the state transition table below.
..............................
start
.............................. ..............................
..............................
..............................
.............................. ..............................
..............................
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
DC (SLM) 108502
© UCLES 2015 [Turn over
59
2
Throughout the paper you will be asked to write either pseudocode or program code.
Complete the statement to indicate which high-level programming language you will use.
1 A turnstile is a gate which is in a locked state. To open it and pass through, a customer inserts
a coin into a slot on the turnstile. The turnstile then unlocks and allows the customer to push the
turnstile and pass through the gate.
After the customer has passed through, the turnstile locks again. If a customer pushes the turnstile
while it is in the locked state, it will remain locked until another coin is inserted.
The turnstile has two possible states: locked and unlocked. The transition from one state to
another is as shown in the table below.
..............................
.............................. ..............................
.............................. ..............................
start ..............................
[5]
2 A declarative programming language is used to represent the knowledge base shown below:
01 capital_city(amman).
02 capital_city(beijing).
03 capital_city(brussels).
04 capital_city(cairo).
05 capital_city(london).
06 city_in_country(amman, jordan).
07 city_in_country(shanghai, china).
08 city_in_country(brussels, belgium).
09 city_in_country(london, uk).
10 city_in_country(manchester, uk).
11 country_in_continent(belgium, europe).
12 country_in_continent(china, asia).
13 country_in_continent(uk, europe).
14 city_visited(amman).
15 city_visited(beijing).
16 city_visited(cairo).
Clause Explanation
01 Amman is a capital city
06 Amman is a city in the country of Jordan
11 Belgium is a country in the continent of Europe
14 The travel writer visited Amman
The travel writer visited the city of Santiago which is the capital city of Chile, in the continent
of South America.
17 ............................................................................................................................................
...................................................................................................................................................
18 ............................................................................................................................................
...................................................................................................................................................
19 ............................................................................................................................................
...................................................................................................................................................
20 ............................................................................................................................................
.............................................................................................................................................. [4]
country_in_continent(ThisCountry, europe)
returns
ThisCountry = belgium, uk
city_in_country(ThisCity, uk)
ThisCity = ...........................................................................................................................
.............................................................................................................................................. [2]
(c) Complete the rule below to list the countries the travel writer has visited.
countries_visited(ThisCountry)
IF .............................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [4]
3 A shop gives some customers a discount on goods totalling more than $20.
The discounts are:
• 5% for goods totalling more than $100
• 5% with a discount card
• 10% with a discount card and goods totalling more than $100
goods totalling
Y Y Y Y N N N N
more than $20
Conditions
goods totalling
Y Y N N Y Y N N
more than $100
No discount
Actions
5% discount
10% discount
[4]
goods totalling
more than $20
Conditions
goods totalling
more than $100
No discount
Actions
5% discount
10% discount
[5]
(c) The simplified table produced in part (b) is used as a design for program code.
The following identifier table shows the parameters to be passed to the function Discount.
This function returns the discount amount as an integer.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [6]
[3]
• methods
• SetEmployeeName
• SetEmployeeID
• CalculatePay
Write program code for the class definition of the superclass Employee.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [5]
© UCLES 2015 9608/42/M/J/15
66
9
(c) (i) State the properties and/or methods required for the subclass HourlyPaidEmployee.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [4]
(ii) State the properties and/or methods required for the subclass SalariedEmployee.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
(d) Name the feature of object-oriented program design that allows the method CalculatePay
to be declared in the superclass Employee.
...................................................................................................................................................
.............................................................................................................................................. [1]
(ii) A special case is when NameList is already in order. The algorithm in part (a)(i) is
applied to this special case.
Explain how many iterations are carried out for each of the loops.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [3]
FOR ThisPointer ← 1 TO 9
FOR Pointer ← 1 TO 9
IF NameList[Pointer] > NameList[Pointer + 1]
THEN
Temp ← NameList[Pointer]
NameList[Pointer] ← NameList[Pointer + 1]
NameList[Pointer + 1] ← Temp
ENDIF
ENDFOR
ENDFOR
(i) As in part (a)(ii), a special case is when NameList is already in order. The algorithm in
part (b) is applied to this special case.
Explain how many iterations are carried out for each of the loops.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
(ii) Rewrite the algorithm in part (b), using pseudocode, to reduce the number of
unnecessary comparisons. Use the same variable names where appropriate.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [5]
• create queue
• add item to queue
• remove item from queue
CreateQueue
AddName("Ali")
AddName("Jack")
AddName("Ben")
AddName("Ahmed")
RemoveName
AddName("Jatinder")
RemoveName
Add appropriate labels to the diagram to show the final state of the queue. Use the space on
the left as a workspace. Show your final answer in the node shapes on the right:
[3]
TYPE Node
DECLARE Name : STRING
DECLARE Pointer : INTEGER
ENDTYPE
The statement
(i) The CreateQueue operation links all nodes and initialises the three pointers that need
to be used: HeadPointer, TailPointer and FreePointer.
Complete the diagram to show the value of all pointers after CreateQueue has been
executed.
Queue
HeadPointer Name Pointer
[1]
[2]
TailPointer [3]
[4]
[5]
FreePointer [6]
[7]
[8]
[9]
[10]
[4]
(ii) The algorithm for adding a name to the queue is written, using pseudocode, as a
procedure with the header:
PROCEDURE AddName(NewName)
Complete the pseudocode for the procedure RemoveName. Use the variables listed in
the identifier table.
PROCEDURE RemoveName()
// Report error if Queue is empty
...........................................................................................................................
...........................................................................................................................
...........................................................................................................................
...........................................................................................................................
OUTPUT Queue[…………………………………………………………].Name
// current node is head of queue
...........................................................................................................................
// update head pointer
...........................................................................................................................
// if only one element in queue then update tail pointer
...........................................................................................................................
...........................................................................................................................
...........................................................................................................................
...........................................................................................................................
// link released node to free list
...........................................................................................................................
...........................................................................................................................
...........................................................................................................................
ENDPROCEDURE
[6]
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every reasonable
effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the publisher will
be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.
Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.
This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of
the examination. It shows the basis on which Examiners were instructed to award marks. It does not
indicate the details of the discussions that took place at an Examiners’ meeting before marking began,
which would have considered the acceptability of alternative answers.
Mark schemes should be read in conjunction with the question paper and the Principal Examiner
Report for Teachers.
Cambridge will not enter into discussions about these mark schemes.
Cambridge is publishing the mark schemes for the May/June 2015 series for most
Cambridge IGCSE®, Cambridge International A and AS Level components and some
Cambridge O Level components.
Insert coin
locked unlocked
Attempt to
push insert coin
Pass through
start
Mark as follows:
1 mark for both states correct
1 mark for each further label [5]
2 (a) capital_city(santiago).
city_in_country(santiago, chile).
country_in_continent(chile,south_america).
city_visited(santiago).
(b) ThisCity =
manchester
london [2]
(c) countries_visited(ThisCountry)
IF
city_visited(ThisCity) 1
AND 1
city_in_country(ThisCity, ThisCountry) 2 [4]
3 (a)
goods totalling
Y Y Y Y N N N N
more than $20
Conditions
goods totalling
Y Y N N Y Y N N
more than $100
No discount X X X X X
Actions
5% discount X X
10% discount X
1 1 1
1 mark
mark mark mark
[4]
(b)
goods totalling
Y Y Y Y N
more than $20
Conditions
goods totalling
Y Y N N -
more than $100
No discount X X
Actions
5% discount X X
10% discount X
BEGIN
(1) IF GoodsTotal > 20
(1) THEN
(2) IF GoodsTotal > 100
(2) THEN
(3) IF HasDiscountCard = TRUE
(3) THEN
(3) Discount := 10
(3) ELSE
(3) Discount := 5
(2) ELSE
(4) IF HasDiscountCard = TRUE
(4) THEN
(4) Discount := 5
(4) ELSE
(4) Discount := 0
(1) ELSE
(1) Discount := 0;
END;
Example Python
4 (a)
[3]
Mark as follows:
Class header (1 mark)
PUBLIC and PRIVATE used correctly (1 mark)
EmployeeName + EmployeeID (1 mark)
AmountPaidThisMonth (1 mark)
Methods x 3 (1 mark)
Example VB
Class Employee
Private EmployeeName As String
Private EmployeeID As String
Private AmountPaidThisMonth As Decimal
Public Sub SetEmployeeName()
End Sub
Public Sub SetEmployeeID()
End Sub
Public Sub CalculatePay()
End Sub
Example Python
Class Employee():
def __init__(self):
self.__EmployeeName = ""
self.__EmployeeID = ""
self.__AmountPaidThisMonth = 0
def SetEmployeeName(self, Name):
self.__EmployeeName = Name
def SetEmployeeID(self, ID):
self.__EmployeeID = ID
def SetAmountPaidThisMonth(self, Paid):
self.__AmountPaidThisMonth = Paid [max 5]
(ii) AnnualSalary 1
SetSalary 1
CalculatePay : Override 1 [max 2]
(ii) NumberOfItems 10
REPEAT
NoMoreSwaps TRUE
Mark as follows:
• change outer loop to a REPEAT/WHILE loop (1 mark)
• FOR loop has variable used for final value (1 mark)
• Initialise Boolean variable to TRUE (1 mark)
• set Boolean variable to FALSE in correct place (1 mark)
• number of items to consider on each pass decrements (1 mark)
• Correct stopping condition for REPEAT loop (1 mark) [max 5]
6 (a)
Head Ben
Ahmed
Tail Jatinder 0
(b) (i)
Queue
0 [1] 2
[2] 3
TailPointer [3] 4
0 [4] 5
[5] 6
FreePointer [6] 7
1 [7] 8
[8] 9
[9] 10
[10] 0
Mark as follows:
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
DC (AC/SW) 95230/2
© UCLES 2015 [Turn over
84
2
Throughout the paper you will be asked to write either pseudocode or program code.
Complete the statement to indicate which high-level programming language you will use.
A customer can use the petrol pump when it is ready to dispense petrol.
The pump is in use when the customer takes the nozzle from a holster on the pump.
The pump dispenses petrol while the customer presses the trigger on the nozzle.
When the customer replaces the nozzle into the holster, the pump is out of use.
The cashier must press a reset button to make the pump ready for the next customer to use.
The petrol pump’s four possible states and the transition from one state to another are as shown in
the table below.
...........................
start
........................... ...........................
...........................
...........................
........................... ...........................
........................... ...........................
[9]
2 A declarative programming language is used to represent the knowledge base shown below:
01 dairy_product(cheese).
02 meat(beef).
03 meat(chicken).
04 meat(lamb).
05 made_with(burger, beef).
06 made_with(kofta, lamb).
07 made_with(quiche, cheese).
08 made_with(quiche, egg).
09 made_with(quiche, flour).
Clause Explanation
01 Cheese is a dairy product
02 Beef is a meat
05 A burger is made with beef
10 ..............................................................................................................................................
...................................................................................................................................................
11 ..............................................................................................................................................
...................................................................................................................................................
12 ..............................................................................................................................................
...................................................................................................................................................
13 ..............................................................................................................................................
.............................................................................................................................................. [4]
meat(TypeOfMeat)
returns
made_with(quiche, Ingredient)
Ingredient = .........................................................................................................................
.............................................................................................................................................. [2]
(c) Complete the rule to list the dishes made with meat.
contains_meat(Dish)
IF .............................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [4]
3 An insurance company calculates the cost of car insurance from a basic price.
Age under 25 Y Y Y Y N N N N
Conditions
Previous accident Y Y N N Y Y N N
No discount
5% discount
[6]
Age under 25
Conditions
Previous accident
No discount
5% discount
[3]
(c) The simplified table produced in part (b) is used as a design for program code.
The following identifier table shows the parameters to be passed to the function
CostPercentageChange. This function returns the percentage change from the basic price
as an integer. A discount should be shown as a negative integer. An extra charge should be
shown as a positive integer.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [6]
4 A sports club stores data about its members. A program is to be written using an object-oriented
programming language.
[3]
• properties
• MemberName
• MemberID
• SubscriptionPaid
• methods
• SetMemberName
• SetMemberID
• SetSubscriptionPaid
Write program code for the class definition of the superclass Member.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..................................................................................................................................................... [5]
(i) Write program code for the class definition for the subclass JuniorMember.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [3]
(ii) Write program code to create a new instance of JuniorMember. Use identifier
NewMember with the following data:
name Ahmed with member ID 12347, born on 12/11/2001, who has paid his subscription.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [3]
• create stack
• add item to stack (push)
• remove item from stack (pop)
(a) There is one pointer: the top of stack pointer, which points to the last item added to the stack.
Draw a diagram to show the final state of the stack after the following operations are carried
out.
CreateStack
Push("Ali")
Push("Jack")
Pop
Push("Ben")
Push("Ahmed")
Pop
Push("Jatinder")
Add appropriate labels to the diagram to show the final state of the stack. Use the space on the left
as a workspace. Show your final answer in the node shapes on the right:
[3]
TYPE Node
DECLARE Name : STRING
DECLARE Pointer : INTEGER
ENDTYPE
The statement
(i) The CreateStack operation links all nodes and initialises the TopOfStackPointer
and FreePointer.
Complete the diagram to show the value of all pointers after CreateStack has been
executed.
Stack
TopOfStackPointer Name Pointer
[1]
[2]
FreePointer [3]
[4]
[5]
[6]
[7]
[8]
[9]
[10]
[4]
(ii) The algorithm for adding a name to the stack is written, using pseudocode, as a
procedure with the header
Where NewName is the new name to be added to the stack. The procedure uses the
variables as shown in the identifier table.
Complete the pseudocode for the procedure Pop. Use the variables listed in the identifier table.
PROCEDURE Pop()
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
ENDPROCEDURE
[5]
...................................................................................................................................................
.............................................................................................................................................. [1]
(b) Explain how a stack is used during the execution of a recursive procedure.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [2]
(c) Dry run the procedure X by completing the trace table for the procedure call:
CALL X(40)
Call
n (n = 0) OR (n = 1) n DIV 2 n MOD 2
number
1 40 FALSE 20
2
3
4
5
6
...................................................................................................................................................
.............................................................................................................................................. [1]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [5]
This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of
the examination. It shows the basis on which Examiners were instructed to award marks. It does not
indicate the details of the discussions that took place at an Examiners’ meeting before marking began,
which would have considered the acceptability of alternative answers.
Mark schemes should be read in conjunction with the question paper and the Principal Examiner
Report for Teachers.
Cambridge will not enter into discussions about these mark schemes.
Cambridge is publishing the mark schemes for the May/June 2015 series for most
Cambridge IGCSE®, Cambridge International A and AS Level components and some
Cambridge O Level components.
1
Take nozzle
start
Press trigger
Replace nozzle
[9]
(b) Ingredient =
cheese, egg, flour [2]
(c) contains_meat(Dish)
IF
made_with(Dish, X) (2 marks)
AND (1 mark)
meat(X) (1 mark) [4]
3 (a)
Age under 25 Y Y Y Y N N N N
Conditions
Previous accident Y Y N N Y Y N N
No discount X X X X
5% discount X X X
1 1 1 1
1 mark 1 mark
mark mark mark mark
[6]
(b)
Age under 25 Y Y Y Y N N
Conditions
Previous accident Y Y N N Y N
No discount X X X
5% discount X X
1 1
1 mark
mark mark
[3]
Example Python
Mark as follows:
Correct function header
Correct IF statement (1)
Correct IF statement (2)
Correct IF statement (3)
Correct IF statement (4)
Correct IF statement (5)
Correct return statement (or equivalent) [max 6]
OR equivalent demonstrating correct logic
4 (a)
[3]
Member = CLASS
PUBLIC
Procedure SetMemberName;
Procedure SetMemberID;
Procedure SetSubscriptionPaid;
PRIVATE
MemberName : STRING;
MemberID : STRING;
SubscriptionPaid : Boolean;
END;
Example Python
class Member() :
def__init__(self): PUBLIC
self.__MemberName = ""
self.__MemberID = ""
self.__SubscriptionPaid = False
def SetMemberName(self, Name):
self.MemberName = Name
def SetMemberID(self, ID):
self.MemberID = ID
def SetSubscriptionPaid(self, Paid):
self.SubscriptioPaid = Paid
Mark as follows:
Class header (1 mark)
Public and Private used correctly (1 mark)
MemberName + MemberID (1 mark)
SubscriptionPaid (1 mark)
Methods × 3 (1 mark) [5]
Example Python
class JuniorMember (Member):
def__init__self:
super().__init__()
self.DateOfBirth = ""
def SetDateOfBirth(self, Date):
self.DateOfBirth = Date
def SetMemberName(self, Name):
super().SetMemberName(Name)
def SetMemberID(self, ID):
super().SetMemberID(ID)
def SetSubscriptionPaid(self, Paid):
super().SetSubscriptioPaid(Paid) [3]
Example Python
5 (a)
Top of
Stack Jatinder
Ben
Ali 0
(b) (i)
Stack
0 [1] 2
[2] 3
FreePointer [3] 4
1 [4] 5
[5] 6
[6] 7
[7] 8
[8] 9
[9] 10
[10] 0
Mark as follows:
TopOfStackPointer
FreePointer
Pointers[1] to [9]
Pointer[10] [4]
1 mark for each line of code as above (first 4 lines + ENDIF for 1 mark) [Max 5]
(b) Before procedure call is executed current state of the registers/local variables is saved onto
the stack
When returning from a procedure call the registers/local variables are re-instated [2]
(c)
1 40 FALSE 20 0
2 20 FALSE 10 0
3 10 FALSE 5 0
4 5 FALSE 2 1
5 2 FALSE 1 0
6 1 TRUE
Example Python
def X(n):
if (n == 0) or (n == 1):
print(n, end="")
else:
X(n // 2)
print(n % 2, end="")
Mark as follows:
Procedure heading & ending
Boolean expression
correctly grouped statements within ELSE
recursive call
Using DIV and MOD correctly [5]
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
DC (ST) 95544/3
© UCLES 2015 [Turn over
109
2
1 In a particular computer system, real numbers are stored using floating-point representation with:
(a) (i) A real number is stored as the following 12-bit binary pattern:
0 1 1 0 1 0 0 0 0 0 1 1
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
(ii) Give the normalised binary pattern for +3.5. Show your working.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
(iii) Give the normalised binary pattern for –3.5. Show your working.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
(b) (i) If the system were to use the extra 4 bits for the mantissa, state what the effect would be
on the numbers that can be represented.
...........................................................................................................................................
.......................................................................................................................................[1]
(ii) If the system were to use the extra 4 bits for the exponent instead, state what the effect
would be on the numbers that can be represented.
...........................................................................................................................................
.......................................................................................................................................[1]
0.3000000000000001
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[3]
2 In this question, you are shown pseudocode in place of a real high-level language. A compiler
uses a keyword table and a symbol table. Part of the keyword table is shown below.
Keyword Token
01
+ 02
= 03
IF 4A
THEN 4B
ENDIF 4C
ELSE 4D
FOR 4E
STEP 4F
TO 50
INPUT 51
OUTPUT 52
ENDFOR 53
Entries in the symbol table are allocated tokens. These values start from 60 (hexadecimal).
Start 0.1
// Output values in loop
FOR Counter Start TO 10
OUTPUT Counter + Start
ENDFOR
(a) Complete the symbol table below to show its contents after the lexical analysis stage.
Token
Symbol
Value Type
Start 60 Variable
0.1 61 Constant
[3]
© UCLES 2015 9608/32/O/N/15
112
5
(b) Each cell below represents one byte of the output from the lexical analysis stage.
Using the keyword table and your answer to part (a) complete the output from the lexical
analysis.
60 01
[2]
(c) The compilation process has a number of stages. The output of the lexical analysis stage
forms the input to the next stage.
.......................................................................................................................................[1]
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
(d) The final stage of compilation is optimisation. There are a number of reasons for performing
optimisation. One reason is to produce code that minimises the amount of memory used.
.......................................................................................................................................[1]
A B + 2 * 6
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[1]
X A + B
Y A + B + C
Following the syntax analysis stage, object code is generated. The equivalent code, in
assembly language, is shown below:
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[2]
(b) There are many applications in which digital data are transferred across a network. Video
conferencing is one of these.
For this application, circuit switching is preferable to the use of packet switching.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[6]
(c) A web page is transferred from a web server to a home computer using the Internet.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[3]
© UCLES 2015 9608/32/O/N/15 [Turn over
115
8
4 (a) Four descriptions and four types of computer architecture are shown below.
Draw a line to connect each description to the appropriate type of computer architecture.
[4]
(b) In a massively parallel computer explain what is meant by:
...........................................................................................................................................
.......................................................................................................................................[1]
...........................................................................................................................................
.......................................................................................................................................[1]
(c) There are both hardware and software issues that have to be considered for parallel
processing to succeed.
Hardware ..................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Software ....................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[4]
© UCLES 2015 9608/32/O/N/15
116
9
5 (a) (i) Complete the Boolean function that corresponds to the following truth table.
INPUT OUTPUT
P Q R Z
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 0
1 0 0 1
1 0 1 1
1 1 0 0
1 1 1 1
Z = P . Q . R + ................................................................................................................[3]
The part to the right of the equals sign is known as the sum-of-products.
(ii) For the truth table above complete the Karnaugh Map (K-map).
PQ
00 01 11 10
0
R
1
[1]
(iii) Draw loop(s) around appropriate groups of 1’s to produce an optimal sum-of-products.
[2]
(iv) Using your answer to part (a)(iii), write the simplified sum-of-products Boolean function.
Z = .................................................................................................................................[1]
(b) The truth table for a logic circuit with four inputs is given below:
INPUT OUTPUT
P Q R S Z
0 0 0 0 0
0 0 0 1 0
0 0 1 0 0
0 0 1 1 0
0 1 0 0 0
0 1 0 1 1
0 1 1 0 0
0 1 1 1 1
1 0 0 0 0
1 0 0 1 1
1 0 1 0 0
1 0 1 1 0
1 1 0 0 0
1 1 0 1 1
1 1 1 0 0
1 1 1 1 1
PQ
RS
[4]
(ii) Draw loop(s) around appropriate groups of 1’s to produce an optimal sum-of-products.
[2]
(iii) Using your answer to part (b)(ii), write the simplified sum-of-products Boolean function.
Z = .................................................................................................................................[2]
(a) For each of the following, the process is moved from the first state to the second state.
Describe the conditions that cause each of the following changes of state of a process:
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[4]
(b) Explain why a process cannot move directly from the ready state to the blocked state.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[3]
(c) A process in the running state can change its state to something which is neither the ready
state nor the blocked state.
.......................................................................................................................................[1]
.......................................................................................................................................[1]
(d) Explain the role of the low-level scheduler in a multiprogramming operating system.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[2]
© UCLES 2015 9608/32/O/N/15
119
This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of
the examination. It shows the basis on which Examiners were instructed to award marks. It does not
indicate the details of the discussions that took place at an Examiners’ meeting before marking began,
which would have considered the acceptability of alternative answers.
Mark schemes should be read in conjunction with the question paper and the Principal Examiner
Report for Teachers.
Cambridge will not enter into discussions about these mark schemes.
Cambridge is publishing the mark schemes for the October/November 2015 series for most
Cambridge IGCSE®, Cambridge International A and AS Level components and some
Cambridge O Level components.
(ii) +3.5
= 11.1 [1]
= 0.111 × 22 (or indication of moving binary point correctly) [1]
= 01110000 0010 [1]
[Total: 14]
2 (a)
Token
Symbol
Value Type
Start 60 Variable
0.1 61 Constant
10 63 Constant [1+1]
(b)
60 01 61 4E 62 01 60 50 63 52 62 02 60 53
[1+1]
(d) (i) Minimise the execution time // code runs faster [1]
(ii) Compiler could calculate 2*6 and replace it with the value 12. [1]
(b) e.g.
cs: gives dedicated circuit [1]
ps: split into packets/chunks [1]
ps: sends packets on individual routes [1]
cs: whole bandwidth available // ps: shares bandwidth [1]
cs: faster data transfer [1]
cs: packets arrive in order they are sent [1]
cs: packets cannot get lost [1]
cs: better for a real-time application [1]
ps: packets may arrive out of order so delay until packet order restored [1]
ps: packets may get lost so retransmission causes delays [1]
[max. 6]
[Total: 11]
4 (a) 1 mark for correct arrow from each description
Computer
Description Architecture
[4]
[Total: 10]
5 (a) (i)
Z = P. Q . R + [1]
P. Q.R + [1]
P.Q.R [1]
(ii)
PQ
00 01 11 10
0 0 0 0 1
R
1 0 0 1 1
[1]
00 01 11 10
0 0 0 0 1
R
1 0 0 1 1
(iv)
Z=
P. Q [1]
+ P.R [1]
00 01 11 10
00 0 0 0 0
01 0 1 1 1
RS
11 0 1 1 0
10 0 0 0 0
[4]
(ii) 1 mark for loop with two 1s; 1 mark for loop with four 1s
PQ
00 01 11 10
00 0 0 0 0
01 0 1 1 1
RS
11 0 1 1 0
10 0 0 0 0
(iii)
Z=
Q.S [1]
+ P.R. S [1]
(b) to be in blocked state process must initiate some I/O operation [1]
to initiate operation process must be executing [1]
if process in ready state cannot be executing/must be in running state [1]
[Total: 11]
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
DC (NH) 117457
© UCLES 2015 [Turn over
126
2
1 In a particular computer system, real numbers are stored using floating-point representation with:
Mantissa Exponent
0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 1
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
(ii) Explain why the floating-point number in part (a)(i) is not normalised.
...........................................................................................................................................
.......................................................................................................................................[2]
Mantissa Exponent
[2]
(b) (i) Write the largest positive number that can be written as a normalised floating-point
number in this format.
Mantissa Exponent
[2]
(ii) Write the smallest positive number that can be written as a normalised floating-point
number in this format.
Mantissa Exponent
[2]
(iii) If a positive number is added to the number in part (b)(i) explain what will happen.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
(c) A student writes a program to output numbers using the following code:
X 0.0
FOR i 0 TO 1000
X X + 0.1
OUTPUT X
ENDFOR
The student is surprised to see that the program outputs the following sequence:
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[3]
2 A compiler uses a keyword table and a symbol table. Part of the keyword table is shown below.
Keyword Token
01
+ 02
= 03
IF 4A
THEN 4B
ENDIF 4C
ELSE 4D
FOR 4E
STEP 4F
TO 50
INPUT 51
OUTPUT 52
ENDFOR 53
Entries in the symbol table are allocated tokens. These values start from 60 (hexadecimal).
Counter 1.5
INPUT Num1
// Check values
IF Counter = Num1
THEN
Num1 Num1 + 5.0
ENDIF
(a) Complete the symbol table below to show its contents after the lexical analysis stage.
Token
Symbol
Value Type
Counter 60 Variable
1.5 61 Constant
[3]
© UCLES 2015 9608/33/O/N/15
129
5
(b) Each cell below represents one byte of the output from the lexical analysis stage.
Using the keyword table and your answer to part (a) complete the output from the lexical
analysis.
60 01
[2]
A B + C + D
After the syntax analysis stage, the compiler generates object code. The equivalent code, in
assembly language, is shown below:
(i) Name the final stage in the compilation process that follows this code generation stage.
.......................................................................................................................................[1]
(ii) Rewrite the equivalent code given above to show the effect of it being processed through
this final stage.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
(iii) State two benefits of the compilation process performing this final stage.
Benefit 1 ............................................................................................................................
...........................................................................................................................................
Benefit 2 ............................................................................................................................
.......................................................................................................................................[2]
3 An email is sent from one email server to another using packet switching.
(a) State two items that are contained in an email packet apart from the data.
1 ................................................................................................................................................
2 ............................................................................................................................................[2]
(b) Explain the role of routers in sending an email from one email server to another.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[3]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[2]
...............................................................................................................................................[1]
(e) Name an application for which the method identified in part (d) is an appropriate solution.
Justify your choice.
Application ................................................................................................................................
Justification ...............................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[3]
4 (a) Three descriptions and two types of processor are shown below.
(b) In a RISC processor three instructions (A followed by B, followed by C) are processed using
pipelining.
The following table shows the five stages that occur when instructions are fetched and
executed.
(i) The ‘A’ in the table indicates that instruction A has been fetched in time interval 1.
Complete the table to show the time interval in which each stage of each instruction (A,
B, C) is carried out.
Time interval
Stage 1 2 3 4 5 6 7 8 9
Fetch instruction A
Decode instruction
Execute instruction
Access operand in memory
Write result to register
[3]
(ii) The completed table shows how pipelining allows instructions to be carried out more
rapidly. Each time interval represents one clock cycle.
Calculate how many clock cycles are saved by the use of pipelining in the above example.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
© UCLES 2015 9608/33/O/N/15
133
9
5 (a) (i) Complete the Boolean function that corresponds to the following truth table.
INPUT OUTPUT
A B C X
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1
X = A . B . C + ................................................................................................................[3]
The part to the right of the equals sign is known as the sum-of-products.
(ii) For the truth table above complete the Karnaugh Map (K-map).
AB
00 01 11 10
0
C
1
[1]
(iii) Draw loop(s) around appropriate groups of 1’s to produce an optimal sum-of-products.
[2]
(iv) Using your answer to part (a)(iii), write the simplified sum-of-products Boolean function.
X = .................................................................................................................................[2]
(b) The truth table for a logic circuit with four inputs is given below:
INPUT OUTPUT
A B C D X
0 0 0 0 0
0 0 0 1 0
0 0 1 0 0
0 0 1 1 0
0 1 0 0 1
0 1 0 1 0
0 1 1 0 1
0 1 1 1 0
1 0 0 0 0
1 0 0 1 0
1 0 1 0 0
1 0 1 1 0
1 1 0 0 1
1 1 0 1 0
1 1 1 0 1
1 1 1 1 1
AB
CD
[4]
(ii) Draw loop(s) around appropriate groups of 1’s to produce an optimal sum-of-products.
[2]
(iii) Using your answer to part (b)(ii), write the simplified sum-of-products Boolean function.
X = .................................................................................................................................[2]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[2]
(b) For each of the following, the process is moved from the first state to the second state.
Describe the conditions that cause each of the following changes of the state of a process:
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[6]
(c) Explain why a process cannot be moved from the blocked state to the running state.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[3]
(d) Explain the role of the high-level scheduler in a multiprogramming operating system.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[2]
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every reasonable
effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the publisher will
be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.
Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.
This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of
the examination. It shows the basis on which Examiners were instructed to award marks. It does not
indicate the details of the discussions that took place at an Examiners’ meeting before marking began,
which would have considered the acceptability of alternative answers.
Mark schemes should be read in conjunction with the question paper and the Principal Examiner
Report for Teachers.
Cambridge will not enter into discussions about these mark schemes.
Cambridge is publishing the mark schemes for the October/November 2015 series for most
Cambridge IGCSE®, Cambridge International A and AS Level components and some
Cambridge O Level components.
2 (a)
Token
Symbol
Value Type
Counter 60 variable
1.5 61 constant
(b)
6 0 6 5 6 4 6 0 6 4 6 0 6 0 6 4
0 1 1 1 2 A 0 3 2 B 2 1 2 2 3 C [1+1]
1 mark for first 2 lines, 1 mark for last 2 lines, with no other lines added
(iii) Code has fewer instructions / occupies less space in memory when executed [1]
minimises execution time of code // code will execute faster [1]
sender’s IP address
receiver’s IP address
packet sequence number
checksum
[Max 2]
4 (a)
Description Type of
processor
Makes extensive use of
general purpose registers RISC I mark for
correct arrow
from each
description
Has a simplified
instruction set
[3]
(b) (i)
Time Interval
stage 1 2 3 4 5 6 7 8 9
Fetch instruction A B C
Decode instruction A B C
(ii)
AB
00 01 11 10
0 0 0 1 0
C
1 0 1 1 0 [1]
(iii)
AB
00 01 11 10
(iv) X =
A.B [1]
+ B.C [1]
Allow f.t. from (iii)
(b) (i)
AB
00 01 11 10
1 mark row headings
00 0 1 1 0
1 mark column headings
01 0 0 0 0
CD 1 mark per 2 correct
rows (based on headings)
11 0 0 1 0
10 0 1 1 0
[4]
(ii)
AB
00 01 11 10
10 0 1 1 0
[2]
(iii) X =
B.D [1]
+ A.B.C [1]
ready, running:
process is capable of using processor (ready state) [1]
OS allocates processor to process so that process can execute (running state) [1]
running, blocked:
process is executing (running state) when it needs to perform I / O operation [1]
placed in blocked state – until I / O operation completed [1]
Candidates should use this material in preparation for the examination. Candidates should attempt the
practical programming tasks using their chosen high-level, procedural programming language.
DC (NH/SW) 111478
© UCLES 2015 [Turn over
145
2
This material is intended to be read by teachers and candidates prior to the November 2015 examination
for 9608 Paper 4.
Reminders
The syllabus states:
• there will be questions on the examination paper which do not relate to this pre-release
material
• you must choose a high-level programming language from this list:
ͦ Visual Basic (console mode)
ͦ Python
ͦ Pascal / Delphi (console mode)
The practical skills covered in Paper 2 are a precursor to those required in Paper 4. It is therefore
recommended that the high-level programming language chosen for this paper is the same as that for
Paper 2. This allows for sufficient expertise to be acquired with the opportunity for extensive practice.
TASK 1
The unique registration and the charge (in $) per unit time are stored for all taxis.
Data stored about minibuses also includes an extra charge (in $) per booking and the maximum
number of passengers allowed.
The superclass (also known as base class or parent class) Taxi is designed.
Two subclasses (also known as derived classes or child classes) have been identified:
• Car
• Minibus
Key focus: Object-oriented Programming
TASK 1.1
Complete the inheritance diagram.
TASK 1.2
Complete the class diagram showing the appropriate properties and methods.
.......................................................................
.......................................................................
.......................................................................
.......................................................................
.......................................................................
.......................................................................
.......................................................................
....................................................................... .......................................................................
....................................................................... .......................................................................
....................................................................... .......................................................................
....................................................................... .......................................................................
Constructor() .......................................................................
....................................................................... .......................................................................
....................................................................... .......................................................................
....................................................................... .......................................................................
Note: a constructor is a method that creates a new instance of a class and initialises it.
TASK 1.3
Write program code for the class definitions. Make use of polymorphism and inheritance where
appropriate.
TASK 1.4
Write program code to create a new instance of Car.
TASK 2
A detailed program specification has been written. The program will consist of seven different menu
options handled from a main module by calling seven different procedures. These modules can be
coded independently.
All procedures and the main module are each estimated to take 3 hours to code and 2 hours to test.
TASK 2.1
The project manager initially has one programmer available to write and test the program. The
programmer works 10 hours a day. Calculate how many days it takes before the customer can start
acceptance testing.
TASK 2.2
The customer is not happy about the proposed development time and the project manager considers
hiring extra staff.
One proposal is to deploy one programmer and one software tester to the project.
The project manager needs a PERT chart to calculate the critical path.
1 3 4 5
2
Key focus: Project management
using a PERT chart
Calculate the shortest time (in days) before the client can start acceptance testing.
TASK 2.3
Another proposal is to deploy four programmers, who each carry out their own module testing.
TASK 2.3.1
Draw a GANTT chart for this proposal.
Key focus: Project management using
a GANTT chart
Activity
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Hour number
1
2
3
4
5
6
7
8
9
TASK 2.3.2
If the programmers each work 10 hours a day, calculate how many days it takes before the customer
can start acceptance testing.
TASK 3
• The key field of a book record is the ISBN (a 9-digit string and a check digit).
• Other book data are stored.
• A hashing function is used to calculate a record address.
(The first 3 digits of the ISBN are used as the record address.)
• The random file initially consists of dummy records.
• Dummy records are shown by the ISBN set to 0000000000.
The Hash function assumes the existence of the function LeftToInt, defined below:
TASK 3.1
Write program code to implement the functions LeftToInt and Hash.
TASK 3.2
Write program code to implement the following pseudocode which initialises a random file:
TYPE BookRecord
DECLARE ISBN : STRING[10] // need fixed-length records for
DECLARE Title : STRING[24] // random files
DECLARE OnLoan : BOOLEAN
ENDTYPE
DummyRecord.ISBN ← "0000000000"
TASK 3.3
Write program code to implement the following pseudocode to input 5 book records:
Test your program by inputting book details with ISBNs that will hash to different addresses.
TASK 3.4
You need to test that the records have been saved successfully.
Write program code to read records sequentially from the random file BookFile and output any non-
zero records.
© UCLES 2015 9608/42/PRE/O/N/15
152
9
TASK 3.5
Key focus: Exception handling
To avoid this, you need to write exception handling code to give an error message instead.
Edit your program code from Task 3.3 to handle the case when "BookFile" does not exist.
TASK 3.6
Add a book record with an ISBN that will cause a collision (also known as a synonym).
Run your program from Task 3.4 again. What do you notice?
TASK 3.7
The pseudocode in Task 3.3 needs amending to handle a collision.
The following algorithm needs to be inserted between line 080 and 090.
2 hours
Candidates answer on the Question Paper.
No Additional Materials are required.
No calculators allowed.
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
DC (AC) 95228/3
© UCLES 2015 [Turn over
154
2
Throughout the paper you will be asked to write either pseudocode or program code.
Complete the statement to indicate which high-level programming language you will use.
1 A large software house has been asked to supply a computerised solution for a business. The
project manager has drawn up a list of activities and their likely duration.
Weeks to
Activity Description
complete
A Write requirement specification 1
B Produce program design 1
C Write module code 7
D Module testing 2
E Integration testing 2
F Alpha testing 2
G Install software and carry out acceptance testing 2
H Research and order hardware 1
J Install delivered hardware 3
K Write technical documentation 4
L Write user training guide 2
M Train users on installed hardware and software 1
N Sign off final system 1
Activity
A
B
C
D
E
F
G
H
J
K
L
M
N
Week
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
number
1
2
3
4
5
6
7
8
9
• Activity E showed that the code contained major errors. The senior programmer now
estimates that:
• further module coding will require another 2 weeks
• further module testing will require another 2 weeks
• further integration testing will require another 2 weeks
• The hardware delivery is delayed by 16 weeks.
Activity
A
B
C
D
E
F
G
H
J
K
L
M
N
Week
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
number
1
2
3
4
5
6
7
8
9
[9]
2 A declarative programming language is used to represent the following facts and rules:
01 male(ahmed).
02 male(raul).
03 male(ali).
04 male(philippe).
05 female(aisha).
06 female(gina).
07 female(meena).
08 parent(ahmed, raul).
09 parent(aisha, raul).
10 parent(ahmed, philippe).
11 parent(aisha, philippe).
12 parent(ahmed, gina).
13 parent(aisha, gina).
14 mother(A, B) IF female(A) AND parent(A, B).
Clause Explanation
01 Ahmed is male
05 Aisha is female
08 Ahmed is a parent of Raul
14 A is the mother of B if A is female and A is a parent of B
15 ............................................................................................................................................
16 ....................................................................................................................................... [2]
parent(ahmed, C)
returns
parent(P, gina)
P = ....................................................................................................................................... [2]
(c) Use the variable M to write the goal to find the mother of Gina.
.............................................................................................................................................. [1]
father(F, C)
IF .............................................................................................................................................
.............................................................................................................................................. [2]
brother(X, Y)
IF .............................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [4]
A part-time student attends one or more courses. A fee is charged for each course. The number of
courses a part-time student attends is recorded, along with the total fee and whether or not the fee
has been paid.
The college needs a program to process data about its students. The program will use an object-
oriented programming language.
(a) Complete the class diagram showing the appropriate properties and methods.
Student
StudentName: STRING
........................................................................
........................................................................
........................................................................
ShowStudentName()
........................................................................
........................................................................
........................................................................
FullTimeStudent PartTimeStudent
Address: STRING
.......................................................................
.......................................................................
.......................................................................
.......................................................................
.......................................................................
.......................................................................
.......................................................................
Constructor()
.......................................................................
ShowAddress()
.......................................................................
.......................................................................
.......................................................................
.......................................................................
.......................................................................
[7]
© UCLES 2015 9608/42/O/N/15
159
7
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [3]
• identifier: NewStudent
• name: A. Nyone
• date of birth: 12/11/1990
• telephone number: 099111
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [3]
The dictionary ADT is to be implemented as a two-dimensional array. This stores key-value pairs.
The CreateDictionary operation initialises all elements of Dictionary to the empty string.
(a) The hashing function Hash is to extract the first letter of the key and return the position of this
letter in the alphabet. For example Hash("Action") will return the integer value 1.
(Note: The ASCII code for the letter A is 65.)
Number ← ...........................................................................................................................
............................................................................................................................................
ENDFUNCTION
[5]
(b) The algorithm for adding a new key-value pair to the dictionary is written, using pseudocode,
as a procedure.
(i) Dry-run the following procedure calls by writing the keys and values in the correct
elements of Dictionary.
Add("File", "Datei")
Add("Disk", "Platte")
Add("Error", "Fehler")
Add("Computer", "Rechner")
Dictionary
Index Key Value
1
2
3
4
5
6
7
8
:
:
1999
2000
[2]
Explain the problem that occurs when this key-value pair is saved.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
© UCLES 2015 9608/42/O/N/15 [Turn over
162
10
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
(iv) Write pseudocode to implement the method you described in part (b) (iii). Choose line
numbers to indicate where your pseudocode should be inserted in the given pseudocode.
20 Index ← Hash(NewKey)
50 ENDPROCEDURE
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [4]
5 The table shows assembly language instructions for a processor which has one general purpose
register – the Accumulator (ACC).
Instruction
Explanation
Op Code Operand
LDM #n Immediate addressing. Load the number n to ACC
LDD <address> Direct addressing. Load the contents of the given address to ACC
STO <address> Store the contents of ACC at the given address
ADD <address> Add the contents of the given address to the ACC
INC <register> Add 1 to the contents of the register
CMP <address> Compare the contents of ACC with the contents of <address>
JPN <address> Following a compare instruction, jump to <address> if the compare
was False
END Return control to the operating system
(a) (i) Dry-run this assembly language program using the trace table.
508 END
509 7
510 3
511 0
512 0
Trace table
Memory address
Accumulator 509 510 511 512
7 3 0 0
[5]
(ii) Explain the role address 511 has in this assembly language program.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
(b) Using opcodes from the given table, write instructions to set the value at address 509 to 12.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [2]
(a) The record fields are the ProductCode, the Price and the NumberInStock.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [4]
(b) Before records can be read from file StockFile, the file needs to be opened.
01 TRY
02 OPENFILE ...........................................................................................................
03 EXCEPT
04 ..............................................................................................................................
05 ENDTRY
[2]
(ii) Explain the reason for including lines 01, 03, 04, 05.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
(c) A stock report program uses a variable of type StockItem declared as follows:
The program outputs the fields ProductCode and NumberInStock for each record.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [4]
This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of
the examination. It shows the basis on which Examiners were instructed to award marks. It does not
indicate the details of the discussions that took place at an Examiners’ meeting before marking began,
which would have considered the acceptability of alternative answers.
Mark schemes should be read in conjunction with the question paper and the Principal Examiner
Report for Teachers.
Cambridge will not enter into discussions about these mark schemes.
Cambridge is publishing the mark schemes for the October/November 2015 series for most
Cambridge IGCSE®, Cambridge International A and AS Level components and some
Cambridge O Level components.
1 (a) (i)
Activity
A
B
C
D
E
F
G
H
J
K
L
M
N
Week
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Number
1
2
3
4
5
6
7
8
9
(b) (i)
Activity Description Weeks to
complete
A Write requirement specification 1
B Produce program design 1
C Write module code 7
D Module testing 2
E Integration testing 2
F Alpha testing 2
G Install software and carry out acceptance testing 2
H Research and order hardware 1
J Install delivered hardware 3
K Write technical documentation 4
L Write user training guide 2
M Train users on installed hardware and software 1
N Sign off final system 1
Activity
A
B
C
D
E
F
G
H
J
K
L
M
N
Week
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
1
2
3
4
5
6
7
8
9
Number
(b) P =
ahmed
aisha
Ignore capitalisation
Deduct 1 mark for every extra result [2]
(d) father(F, C)
IF
male(F) AND parent(F, C).
(e) brother(X, Y)
IF
male(X)AND [1]
parent(A, X) AND [1]
parent(A, Y) [1]
AND NOT X=Y. [1]
Accept any variable for A, but it must be the same in both places
Accept father/mother instead of parent
Ignore capitalisation
3 (a)
Student
StudentName : STRING
DateOfBirth : DATETIME
………………………………………………………………………………………
ShowStudentName()
ShowDateOfBirth()
………………………………………………………………………………………
FullTimeStudent PartTimeStudent
Address: STRING NumberOfCourses : INTEGER
TelephoneNumber : STRING Fee : Currency
……………………………………………………………………………………… FeePaid : BOOLEAN
Constructor() Constructor()
ShowAddress() ShowNumberOFCourses()
ShowTelephoneNumber() ShowFee()
……………………………………………………………………………………… ShowFeePaid()
Mark as follows:
Base class:
– dateOfBirth declaration and associated method in Student
– constructor
Subclasses:
– telephoneNumber declaration and associated method in FullTimeStudent
– NumberOFCourses declaration and associated method in PartTimeStudent
– fee declaration and associated method in PartTimeStudent
– feepaid declaration and associated method in PartTimeStudent
– constructor method in PartTimeStudent
– inheritance arrows
Pascal
Python
class Student :
def __int__(self) :
self.__StudentName = ""
self.__DateOfBirth = "" # date(1,1,2015)
def ShowStudentName() :
pass
def ShowDateOfBirth() :
pass
VB.NET
Class Student
Public Sub ShowStudentName()
End Sub
Public Sub ShowDateOfBirth()
End Sub
Private StudentName As String
Private DateOfBirth As Date ‘ accept string
End Class
Pascal
TYPE FullTimeStudent = CLASS (Student)
PUBLIC
Procedure ShowAddress();
Procedure ShowTelephoneNumber();
PRIVATE
Address : STRING;
TelephoneNumber : STRING; // reject integer
END;
Python
class FullTimeStudent(Student) :
def __init__(self) :
self.__Address = ""
self.__TelephoneNumber = ""
def ShowAddress() :
pass
def ShowTelephoneNumber() :
pass
VB.NET
Class FullTimeStudent : Inherits Student
Public Sub ShowAddress()
End Sub
Public Sub ShowTelephoneNumber()
End Sub
Private Address As String
Private TelephoneNumber As String ‘ reject integer
End Class
Pascal
NewStudent := FullTimeStudent.Create;
NewStudent.StudentName := 'A.Nyone';
NewStudent.DateOfBirth := EncodeDate(1990, 11,12);//:=
‘11/12/1990’
NewStudent.TelephoneNumber := '099111';
Alternative
NewStudent := FullTimeStudent.Create(‘A.Nyone’, ‘12/11/1990’,
‘099111’);
Python
NewStudent = FullTimeStudent()
NewStudent.StudentName = "A.Nyone"
NewStudent.DateOfBirth = "12/11/1990"
NewStudent.TelephoneNumber = "099111"
Alternative
NewStudent = FullTimeStudent(‘A.Nyone’, ‘12/11/1990’, ‘099111’)
VB.NET
Dim NewStudent As FullTimeStudent = New FullTimeStudent()
NewStudent.StudentName = "A.Nyone"
NewStudent.DateOfBirth = #11/12/1990#
NewStudent.TelephoneNumber = "099111"
Alternative
Dim NewStudent As FullTimeStudent = New
FullTimeStudent(“A.Nyone”, “12/11/1990”, “099111”)
[Max 3]
(b) (i)
Dictionary
Index Key Value
1
2
3 Computer Rechner
4 Disk Platte
5 Error Fehler
6 File Datei
7
8
: :
: :
1999
2000
5 (a) (i)
Memory Address
Accumulator 509 510 511 512
0 7 3 0 0
7 7
0
1 1
7
14 14
1
2 2
14
21 21
2
3 3
If values changed in column 509 or 510 don’t give marks for 511/512 [5]
(ii) stores the counter value for ….// acts as a control variable/counter
How many times the loop has been performed // control the loop
Pascal
TYPE StockItem = RECORD
ProductCode : String; // accept integer
Price : Currency; // accept real
NumberInStock : Integer;
END;
Python
class StockItem :
def __init__(self) :
self.ProductCode = "" # = 0
self.Price = 0.0 # = 0
self.NumberInStock = 0
VB.NET
STRUCTURE StockItem
Dim ProductCode As String ‘ accept integer
Dim Price As Decimal ‘ Double/single
Dim NumberInStock As Integer
END STRUCTURE
VB6
Type StockItem
ProductCode As String ‘ accept integer
Price As Currency ‘ Double/single
NumberInStock As Integer
END Type [4]
(ii) (Line 01) alerts system to check for possible run-time errors (exception)
(Lines 03, 04) handle the exception without the program crashing // keeps program
running// provide alternative statements to execute to avoid run-time error
Candidates should use this material in preparation for the examination. Candidates should attempt the
practical programming tasks using their chosen high-level, procedural programming language.
DC (NH/SW) 111426
© UCLES 2015 [Turn over
181
2
This material is intended to be read by teachers and candidates prior to the November 2015 examination
for 9608 Paper 4.
Reminders
The syllabus states:
• there will be questions on the examination paper which do not relate to this pre-release
material
• you must choose a high-level programming language from this list:
ͦ Visual Basic (console mode)
ͦ Python
ͦ Pascal / Delphi (console mode)
The practical skills covered in Paper 2 are a precursor to those required in Paper 4. It is therefore
recommended that the high-level programming language chosen for this paper is the same as that for
Paper 2. This allows for sufficient expertise to be acquired with the opportunity for extensive practice.
TASK 1
The unique registration and the charge (in $) per unit time are stored for all taxis.
Data stored about minibuses also includes an extra charge (in $) per booking and the maximum
number of passengers allowed.
The superclass (also known as base class or parent class) Taxi is designed.
Two subclasses (also known as derived classes or child classes) have been identified:
• Car
• Minibus
Key focus: Object-oriented Programming
TASK 1.1
Complete the inheritance diagram.
TASK 1.2
Complete the class diagram showing the appropriate properties and methods.
.......................................................................
.......................................................................
.......................................................................
.......................................................................
.......................................................................
.......................................................................
.......................................................................
....................................................................... .......................................................................
....................................................................... .......................................................................
....................................................................... .......................................................................
....................................................................... .......................................................................
Constructor() .......................................................................
....................................................................... .......................................................................
....................................................................... .......................................................................
....................................................................... .......................................................................
Note: a constructor is a method that creates a new instance of a class and initialises it.
TASK 1.3
Write program code for the class definitions. Make use of polymorphism and inheritance where
appropriate.
TASK 1.4
Write program code to create a new instance of Car.
TASK 2
A detailed program specification has been written. The program will consist of seven different menu
options handled from a main module by calling seven different procedures. These modules can be
coded independently.
All procedures and the main module are each estimated to take 3 hours to code and 2 hours to test.
TASK 2.1
The project manager initially has one programmer available to write and test the program. The
programmer works 10 hours a day. Calculate how many days it takes before the customer can start
acceptance testing.
TASK 2.2
The customer is not happy about the proposed development time and the project manager considers
hiring extra staff.
One proposal is to deploy one programmer and one software tester to the project.
The project manager needs a PERT chart to calculate the critical path.
1 3 4 5
2
Key focus: Project management
using a PERT chart
Calculate the shortest time (in days) before the client can start acceptance testing.
TASK 2.3
Another proposal is to deploy four programmers, who each carry out their own module testing.
TASK 2.3.1
Draw a GANTT chart for this proposal.
Key focus: Project management using
a GANTT chart
Activity
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Hour number
1
2
3
4
5
6
7
8
9
TASK 2.3.2
If the programmers each work 10 hours a day, calculate how many days it takes before the customer
can start acceptance testing.
TASK 3
• The key field of a book record is the ISBN (a 9-digit string and a check digit).
• Other book data are stored.
• A hashing function is used to calculate a record address.
(The first 3 digits of the ISBN are used as the record address.)
• The random file initially consists of dummy records.
• Dummy records are shown by the ISBN set to 0000000000.
The Hash function assumes the existence of the function LeftToInt, defined below:
TASK 3.1
Write program code to implement the functions LeftToInt and Hash.
TASK 3.2
Write program code to implement the following pseudocode which initialises a random file:
TYPE BookRecord
DECLARE ISBN : STRING[10] // need fixed-length records for
DECLARE Title : STRING[24] // random files
DECLARE OnLoan : BOOLEAN
ENDTYPE
DummyRecord.ISBN ← "0000000000"
TASK 3.3
Write program code to implement the following pseudocode to input 5 book records:
Test your program by inputting book details with ISBNs that will hash to different addresses.
TASK 3.4
You need to test that the records have been saved successfully.
Write program code to read records sequentially from the random file BookFile and output any non-
zero records.
© UCLES 2015 9608/43/PRE/O/N/15
188
9
TASK 3.5
Key focus: Exception handling
To avoid this, you need to write exception handling code to give an error message instead.
Edit your program code from Task 3.3 to handle the case when "BookFile" does not exist.
TASK 3.6
Add a book record with an ISBN that will cause a collision (also known as a synonym).
Run your program from Task 3.4 again. What do you notice?
TASK 3.7
The pseudocode in Task 3.3 needs amending to handle a collision.
The following algorithm needs to be inserted between line 080 and 090.
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
DC (KN/SW) 115643
© UCLES 2015 [Turn over
190
2
Throughout the paper you will be asked to write either pseudocode or program code.
Complete the statement to indicate which high-level programming language you will use.
1 A large software house has been asked to supply a computerised solution for a business. The
project manager has drawn up a list of activities and their likely duration.
Weeks to
Activity Description
complete
A Write requirement specification 5
B Produce program design 5
C Write module code 15
D Module testing 10
E Integration testing 5
F Alpha testing 3
G Install software and acceptance testing 5
H Write end user training guide 5
J Write technical documentation 10
K End user training 4
L Sign off final system 1
(a) The project manager decides to construct a Program Evaluation Review Technique (PERT)
chart from this data.
1 5 2 3 5 6 3 7 9
A F
10
J
4 8
10
.......................................................................................................................................[2]
(iii) Calculate the minimum number of weeks for the completion of this solution.
.......................................................................................................................................[1]
(c) Give a reason why the project manager used a PERT chart.
...................................................................................................................................................
...............................................................................................................................................[1]
2 A declarative programming language is used to represent the following facts and rules:
01 male(ali).
02 male(raul).
03 male(ahmed).
04 male(philippe).
05 female(meena).
06 female(aisha).
07 female(gina).
08 parent(ali, raul).
09 parent(meena, raul).
10 parent(ali, ahmed).
11 parent(meena, ahmed).
12 parent(ali, aisha).
13 parent(meena, aisha).
14 father(A, B) IF male(A) AND parent(A, B).
Clause Explanation
01 Ali is male
05 Meena is female
08 Ali is a parent of Raul
14 A is the father of B if A is male and A is a parent of B
15 ..........................................................................................................................................
16 ......................................................................................................................................[2]
parent(P, raul)
returns
P = ali, meena
parent(ali, C)
C = ......................................................................................................................................[2]
(c) Use the variable F to write the goal to find the father of Ahmed.
...............................................................................................................................................[1]
mother(X, Y)
IF .............................................................................................................................................
.............................................................................................................................................. [2]
grandparent(W, Z)
IF .............................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[2]
grandfather(G, K)
IF .............................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[2]
3 A lending library stocks two types of item for loan: books and CDs.
All stock items have a title, the date the item was acquired and whether the item is currently out on
loan.
Books have an author and ISBN. CDs have an artist and play time in minutes.
The library needs a program to process data about the stock items. The program will use an
object-oriented programming language.
(a) Complete the class diagram showing the appropriate properties and methods.
StockItem
Title: STRING
......................................................................
......................................................................
......................................................................
ShowTitle()
......................................................................
......................................................................
......................................................................
Book CD
...................................................................... ......................................................................
...................................................................... ......................................................................
...................................................................... ......................................................................
Constructor() ......................................................................
ShowAuthor() ......................................................................
...................................................................... ......................................................................
...................................................................... ......................................................................
[7]
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
4 A binary tree Abstract Data Type (ADT) has these associated operations:
(a) Show the final state of the binary tree after the following operations are carried out.
CreateTree
Add("Dodi")
Add("Farai")
Add("Elli")
Add("George")
Add("Ben")
Add("Celine")
Add("Ali")
[4]
(b) The binary tree ADT is to be implemented as an array of nodes. Each node consists of data
and two pointers.
TYPE Node
DECLARE Name : STRING
DECLARE LeftPointer : INTEGER
DECLARE RightPointer : INTEGER
ENDTYPE
The statement
The CreateTree operation links all nodes into a linked list of free nodes. It also initialises the
RootPointer and FreePointer.
Show the contents of the Tree array and the values of the two pointers, RootPointer and
FreePointer, after the operations given in part (a) have been carried out.
Tree
RootPointer Name LeftPointer RightPointer
[1]
[2]
FreePointer [3]
[4]
[5]
[6]
[7]
[8]
[9]
[10]
[7]
(c) A programmer needs an algorithm for outputting items in ascending order. To design this, the
programmer writes a recursive procedure in pseudocode.
02 IF Tree[Root].LeftPointer .................................................................
03 THEN
04 TraverseTree( .............................................................................)
05 ENDIF
07 IF ........................................................................................................ <> 0
08 THEN
09 TraverseTree( .............................................................................)
10 ENDIF
11 ENDPROCEDURE
[5]
(ii) Explain what is meant by a recursive procedure. Give a line number from the code above
that shows procedure TraverseTree is recursive.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
(iii) Write the pseudocode call required to output all names stored in Tree.
...........................................................................................................................................
.......................................................................................................................................[1]
5 Data about sports club members are stored in a random file of records.
• The key field of a member record is the member ID (range 1000 to 9999).
• Other member data are stored.
• A hashing function is used to calculate a record address.
• The random file initially consists of dummy records.
• Dummy records are shown by member ID set to 0.
RETURN Address
ENDFUNCTION
(a) New members with the following member IDs have joined the sports club:
Indicate where each record should be stored by deleting the zero and writing the member ID
in the correct cell.
MembershipFile
Address MemberID Other member data
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
96 0
97 0
98 0
99 0 [2]
(b) (i) The program stores a new member’s data in the record variable NewMember. The field
MemberID stores the member ID.
20 NewAddress ← ..........................................................................................................
40 SEEK ...........................................................................................................................
(ii) Before records can be saved to the file MembershipFile, the file needs to be opened.
01 TRY
03 EXCEPT
04 ..............................................................................................................................
05 ENDTRY
[2]
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
(iv) Describe a method, without changing the function Hash, to handle the problem identified
in part (b)(iii).
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
(v) Write pseudocode to implement the method you described in part (b)(iv).
Choose line numbers to indicate where your pseudocode should be inserted in the
pseudocode of part (b)(i).
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[4]
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every reasonable
effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the publisher will
be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.
Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.
This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of
the examination. It shows the basis on which Examiners were instructed to award marks. It does not
indicate the details of the discussions that took place at an Examiners’ meeting before marking began,
which would have considered the acceptability of alternative answers.
Mark schemes should be read in conjunction with the question paper and the Principal Examiner
Report for Teachers.
Cambridge will not enter into discussions about these mark schemes.
Cambridge is publishing the mark schemes for the October/November 2015 series for most
Cambridge IGCSE®, Cambridge International A and AS Level components and some
Cambridge O Level components.
1 (a) (i)
5 5 15 5 3 5
A B C E F G
[max. 7]
(ii) 1 – 2 – 3 – 5 – 6 – 7 – 9 – 8 – 10
1–5 scores 1
6–10 scores 1 [2]
(d) mother(X, Y)
IF
female(X) AND parent(X, Y). [2]
(e) grandparent(W, Z)
IF
parent(W,X)
AND parent(X,Z). [2]
(f) grandfather(G, K)
IF
male(G) AND
grandparent(G, K).
alternative:
father(G, X) AND
parent(X, K). [2]
3 (a)
StockItem
Title: STRING
DateAcquired : TDATETIME………………………
OnLoan: BOOLEAN .………………………………………
………………………………………………………………………………………
ShowTitle()
ShowDateAcquired() ……………………………………
ShowOnLoan() …………………………………………………
………………………………………………………………………………………
Book CD
Author: STRING Artist: STRING ……………………………………………
ISBN: STRING………………………………………… Playtime: INTEGER ……………………………………
……………………………………………………………………………………… ………………………………………………………………………………………
……………………………………………………………………………………… ………………………………………………………………………………………
Constructor() Constructor()…………………………………………………
ShowAuthor() ShowArtist() …………………………………………………
ShowISBN()………………………………………………………… ShowPlayTime() ……………………………………………
……………………………………………………………………………………… ………………………………………………………………………………………
[max. 7]
Pascal
StockItem = CLASS
PUBLIC
Procedure ShowTitle();
Procedure ShowDateAcquired();
Procedure ShowOnLoan();
PRIVATE
Title : STRING;
DateAcquired : TDateTime;
OnLoan : Boolean;
END;
Python
class StockItem :
def __int__(self) :
self.__Title = ""
self.__DateAquired = ""
self.__OnLoan = False
def ShowTitle() :
pass
def ShowDateAcquired() :
pass
def ShowOnLoan() :
pass
VB.NET
Class StockItem
Public Sub ShowTitle()
End Sub
Public Sub ShowDateAquired()
End Sub
Public Sub ShowOnLoan()
End Sub
Private Title As String
Private DateAquired As Date
End Class [3]
Pascal
Python
class Book(StockItem) :
def __init__(self) :
self.__Author = ""
self.__ISBN = ""
def ShowAuthor() :
pass
def ShowISBN() :
pass
VB.NET
(iii) Pascal
NewBook := Book.Create; 1
NewBook.Title := 'Computers';
NewBook.Author := 'A.Nyone';
NewBook.ISBN := '099111'; 1
NewBook.DateAcquired := '12/11/2001';
NewBook.OnLoan := FALSE 1
Python
NewBook = Book() 1
NewBook.Title = "Computers"
NewBook.Author = "A.Nyone"
NewBook.ISBN = "099111" 1
NewBook.DateAcquired = "12/11/2001"
NewBook.OnLoan = False 1
VB.NET
4 (a)
[4]
(b)
Tree
[2] Farai 3 4
[5] Ben 7 6
[6] Celine 0 0
[7] Ali 0 0
[8] 9 0
[9] 10 0
[10] 0 0
[7]
5 (a)
MembershipFile
0 0
1 1001
2 7002
3 0
4 0
5 3005
6 0
7 0
8 0
: :
: :
96 4096
97 0
98 2098
99 0
(ii) 01 TRY
02 OPENFILE "MembershipFile" FOR RANDOM
03 EXCEPT
04 OUTPUT "File does not exist"
05 ENDTRY [2]
(iii) collisions/synonyms
The previous record will be overwritten [2]
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
DC (ST/AR) 126657
© UCLES 2016 [Turn over
216
2
1 A Local Area Network (LAN) consists of four computers and one server. The LAN uses a bus
topology.
(a) Complete the diagram below to show how the computers and the File server could be
connected.
Computer
A
Computer
C
[2]
(c) Computer A starts transmitting a packet to Computer C. At exactly the same time, the File
server starts transmitting a packet to Computer D. This causes a problem.
...........................................................................................................................................
.......................................................................................................................................[1]
(ii) Give three steps taken by both Computer A and the File server to allow them to transmit
their packets successfully.
Step 1 ................................................................................................................................
...........................................................................................................................................
Step 2 ................................................................................................................................
...........................................................................................................................................
Step 3 ................................................................................................................................
.......................................................................................................................................[3]
(d) Adding a switch to the LAN changes its topology. Explain how the use of a switch removes the
problem identified in part (c)(i).
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[4]
2 Digital certificates are used in Internet communications. A Certificate Authority (CA) is responsible
for issuing digital certificates.
1 ................................................................................................................................................
2 ................................................................................................................................................
3 ............................................................................................................................................[3]
1 A user starts an application for a digital certificate using their computer. On this computer
a key pair is generated. This key pair consists of a public key and an associated private
key.
2 The user submits the application to the CA. The generated ........ (i) ........ key and
other application data are sent. The key and data are encrypted using
the CA’s ........ (ii) ........ key.
3 The CA creates a digital document containing all necessary data items and signs it using
the CA’s ........ (iii) ........ key.
In the above method there are three missing words. Each missing word is either ‘public’ or
‘private’.
(i) ...........................................................................................................................................
Justification ........................................................................................................................
.......................................................................................................................................[2]
(ii) ...........................................................................................................................................
Justification ........................................................................................................................
.......................................................................................................................................[2]
(iii) ...........................................................................................................................................
Justification ........................................................................................................................
.......................................................................................................................................[2]
Beena’s email program decrypts the encrypted message using her private key.
.......................................................................................................................................[1]
(ii) Explain how Beena can be sure that she has received a message that is authentic (not
corrupted or tampered with) and that it came from Alexa.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
(iii) Name two uses where encrypted message digests are advisable.
1 ........................................................................................................................................
2 ....................................................................................................................................[2]
3 (a) The following diagram shows how applications X, Y and Z can run on a virtual machine
system.
Guest operating
Guest operating system 1
system 2
Hardware
Task 1 ................................................................................................................................
...........................................................................................................................................
Task 2 ................................................................................................................................
.......................................................................................................................................[2]
(ii) Explain the difference between a guest operating system and a host operating
system.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
(b) A company uses a computer as a web server. The manufacturer will no longer support the
computer’s operating system (OS) in six months’ time. The company will then need to decide
on a replacement OS.
The company is also considering changing the web server software when the OS is changed.
Whenever any changes are made, it is important that the web server service is not disrupted.
Use 1 .................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
Use 2 .................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[4]
(ii) The company uses a virtual machine to test possible solutions to the changes that they
will need to make.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
4 (a) Three file organisation methods and two file access methods are shown below.
Draw lines to link each file organisation method to its appropriate file access method or
methods.
serial direct
sequential sequential
random
[4]
(b) A bank has a very large number of customers. The bank stores data for each customer. This
includes:
• A – a file that stores customer personal data. This file is used at the end of each month
for the production of the monthly statement.
• B – a file that stores encrypted personal identification numbers (PINs) for customer bank
cards. This file is accessed when the customer attempts to withdraw cash at a cash
machine (ATM).
• C – a file that stores all customer transaction records for the current month. Every time
the customer makes a transaction, a new record is created.
For each of the files A, B and C, state an appropriate method of organisation. Justify your
choice.
Justification ........................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
Justification ........................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
Justification ........................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
A B X
A 0 0
X 0 1
B 1 0
1 1
[1]
S
Q
Q
R
–
S R Q Q
Initially 1 0 0 1
R changed to 1 1 1
S changed to 0 0 1
S changed to 1 1 1
S and R changed to 0 0 0
[4]
(ii) One of the combinations in the truth table should not be allowed to occur.
State the values of S and R that should not be allowed. Justify your choice.
S = .............................. R = ..............................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
© UCLES 2016 9608/32/M/J/16
225
11
...........................................................................................................................................
.......................................................................................................................................[1]
...........................................................................................................................................
.......................................................................................................................................[1]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[2]
6 An intruder detection system for a large house has four sensors. An 8-bit memory location stores
the output from each sensor in its own bit position.
(a) (i) State the name of the type of system to which intruder detection systems belong.
.......................................................................................................................................[1]
...........................................................................................................................................
.......................................................................................................................................[1]
(b) Name two sensors that could be used in this intruder detection system. Give a reason for
your choice.
Sensor 1 ...................................................................................................................................
Reason .....................................................................................................................................
...................................................................................................................................................
Sensor 2 ...................................................................................................................................
Reason .....................................................................................................................................
...............................................................................................................................................[4]
The intruder system is set up so that the alarm will only sound if two or more sensors have been
triggered.
An assembly language program has been written to process the contents of the memory location.
The table shows part of the instruction set for the processor used.
Instruction
Explanation
Op code Operand
Direct addressing. Load the contents of the given address to
LDD <address>
ACC
STO <address> Store the contents of ACC at the given address
INC <register> Add 1 to the contents of the register (ACC or IX)
ADD <address> Add the contents of the given address to the contents of ACC
Bitwise AND operation of the contents of ACC with the
AND <address>
contents of <address>
CMP #n Compare the contents of ACC with the number n
JMP <address> Jump to the given address
Following a compare instruction, jump to <address> if the
JPE <address>
compare was True
Following a compare instruction, jump to <address> if the
JGT <address> content of ACC is greater than the number used in the
compare instruction
END End the program and return to the operating system
Op code Operand
SENSORS: B00001010
COUNT: 0
VALUE: 1
LOOP: LDD SENSORS
AND VALUE
CMP #0
JPE ZERO
LDD COUNT
INC ACC
STO COUNT
ZERO: LDD VALUE
CMP #8
JPE EXIT
ADD VALUE
STO VALUE
JMP LOOP
EXIT: LDD COUNT
TEST: CMP …
JGT ALARM
(i) Dry run the assembly language code. Start at LOOP and finish when EXIT is reached.
[4]
.......................................................................................................................................[1]
(iii) The intruder detection system is improved and now has eight sensors.
Published
This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.
Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.
Cambridge will not enter into discussions about these mark schemes.
Cambridge is publishing the mark schemes for the May/June 2016 series for most Cambridge IGCSE®,
Cambridge International A and AS Level components and some Cambridge O Level components.
1 (a) Single line joining all four computers and file server 1
One “terminator” at each end 1
(b)
Statement True False
Computer C uses the IP address of 1
Computer A to indicate that the packet is
for Computer A.
Computer B can read the packet sent from 1
Computer C to Computer A.
The File server routes the packet to 1
Computer A.
2 (a) Examples:
Serial number A mark for
Certificate Authority that issued certificate each
CA digital signature correct
Name of company/organisation/individual/subject/owner owning data item –
Certificate
‘Subject’ public key
Period during which Certificate is valid // some relevant date Max 3
(ii) Public 1
The individual does not know the private key of the CA // the individual
only knows the public key of the CA // only the CA can decrypt the
packaged information 1
(iii) Private 1
‘Only’ the CA’s public key will allow decryption of the Certificate //
proving the certificate was issued by the CA 1
(iii) Examples:
Financial transaction 1
Legal document 1
Software distribution 1
Max 2
(ii) Examples:
Using virtual machine means execution of extra code // emulation of 1
some hardware …
4 (a)
File organisation method File access method
1
serial direct
sequential sequential 2
random 1
Max 3
(ii) Random 1
Real-time transaction processing 1
Requires fastest access to data 1
No need to search through records 1
Max 3
(iii) Serial 1
Each new record is appended 1
Transactions are recorded in chronological order 1
File re-organisation not required for each new record // no need for the
records to be sorted
Max 3
5 (a)
A B X
0 0 1
0 1 1
1
1 0 1
1 1 0
(b) (i)
S R Q Q
1 0 0 1
1
1 1 0 1 1
0 1 1 0 1
1
1 1 1 0
0 0 1 1
(ii) S=0R=0 1
Max 3
Max 1
(b) Examples:
Pressure … 1 – sensor
If intruder steps on sensor 1–
justification
Infra-red …
If beam cut by intruder Maximum
2 sensors
Motion / ultrasonic…
Detects any movement in an area
Contact / magnetic …
If door / window opened Max 4
(c) (i)
BITREG COUNT VALUE ACC Mark as
follows:
B00001010 0 1 B00001010
B00000000 1 mark for:
1
COUNT
2 2 column
B00001010
VALUE
B00000010 column
0
First two
1 1 values in
2 ACC
column
4 4
B00001010 Rest of
ACC
B00000000 column
4
8 8
B00001010
B00001000
1
2 2
8 Max 4
(ii) #1 1
(iii) CMP #8 1
CMP #128 1
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
DC (ST/AR) 126658
© UCLES 2016 [Turn over
237
2
1 A Local Area Network (LAN) consists of four computers and one server. The LAN uses a bus
topology.
(a) Complete the diagram below to show how the computers and the File server could be
connected.
Computer
A
Computer
C
[2]
(c) Computer A starts transmitting a packet to Computer C. At exactly the same time, the File
server starts transmitting a packet to Computer D. This causes a problem.
...........................................................................................................................................
.......................................................................................................................................[1]
(ii) Give three steps taken by both Computer A and the File server to allow them to transmit
their packets successfully.
Step 1 ................................................................................................................................
...........................................................................................................................................
Step 2 ................................................................................................................................
...........................................................................................................................................
Step 3 ................................................................................................................................
.......................................................................................................................................[3]
(d) Adding a switch to the LAN changes its topology. Explain how the use of a switch removes the
problem identified in part (c)(i).
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[4]
2 Digital certificates are used in Internet communications. A Certificate Authority (CA) is responsible
for issuing digital certificates.
1 ................................................................................................................................................
2 ................................................................................................................................................
3 ............................................................................................................................................[3]
1 A user starts an application for a digital certificate using their computer. On this computer
a key pair is generated. This key pair consists of a public key and an associated private
key.
2 The user submits the application to the CA. The generated ........ (i) ........ key and
other application data are sent. The key and data are encrypted using
the CA’s ........ (ii) ........ key.
3 The CA creates a digital document containing all necessary data items and signs it using
the CA’s ........ (iii) ........ key.
In the above method there are three missing words. Each missing word is either ‘public’ or
‘private’.
(i) ...........................................................................................................................................
Justification ........................................................................................................................
.......................................................................................................................................[2]
(ii) ...........................................................................................................................................
Justification ........................................................................................................................
.......................................................................................................................................[2]
(iii) ...........................................................................................................................................
Justification ........................................................................................................................
.......................................................................................................................................[2]
Beena’s email program decrypts the encrypted message using her private key.
.......................................................................................................................................[1]
(ii) Explain how Beena can be sure that she has received a message that is authentic (not
corrupted or tampered with) and that it came from Alexa.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
(iii) Name two uses where encrypted message digests are advisable.
1 ........................................................................................................................................
2 ....................................................................................................................................[2]
3 (a) The following diagram shows how applications X, Y and Z can run on a virtual machine
system.
Guest operating
Guest operating system 1
system 2
Hardware
Task 1 ................................................................................................................................
...........................................................................................................................................
Task 2 ................................................................................................................................
.......................................................................................................................................[2]
(ii) Explain the difference between a guest operating system and a host operating
system.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
(b) A company uses a computer as a web server. The manufacturer will no longer support the
computer’s operating system (OS) in six months’ time. The company will then need to decide
on a replacement OS.
The company is also considering changing the web server software when the OS is changed.
Whenever any changes are made, it is important that the web server service is not disrupted.
Use 1 .................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
Use 2 .................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[4]
(ii) The company uses a virtual machine to test possible solutions to the changes that they
will need to make.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
4 (a) Three file organisation methods and two file access methods are shown below.
Draw lines to link each file organisation method to its appropriate file access method or
methods.
serial direct
sequential sequential
random
[4]
(b) A bank has a very large number of customers. The bank stores data for each customer. This
includes:
• A – a file that stores customer personal data. This file is used at the end of each month
for the production of the monthly statement.
• B – a file that stores encrypted personal identification numbers (PINs) for customer bank
cards. This file is accessed when the customer attempts to withdraw cash at a cash
machine (ATM).
• C – a file that stores all customer transaction records for the current month. Every time
the customer makes a transaction, a new record is created.
For each of the files A, B and C, state an appropriate method of organisation. Justify your
choice.
Justification ........................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
Justification ........................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
Justification ........................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
A B X
A 0 0
X 0 1
B 1 0
1 1
[1]
S
Q
Q
R
–
S R Q Q
Initially 1 0 0 1
R changed to 1 1 1
S changed to 0 0 1
S changed to 1 1 1
S and R changed to 0 0 0
[4]
(ii) One of the combinations in the truth table should not be allowed to occur.
State the values of S and R that should not be allowed. Justify your choice.
S = .............................. R = ..............................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
© UCLES 2016 9608/33/M/J/16
246
11
...........................................................................................................................................
.......................................................................................................................................[1]
...........................................................................................................................................
.......................................................................................................................................[1]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[2]
6 An intruder detection system for a large house has four sensors. An 8-bit memory location stores
the output from each sensor in its own bit position.
(a) (i) State the name of the type of system to which intruder detection systems belong.
.......................................................................................................................................[1]
...........................................................................................................................................
.......................................................................................................................................[1]
(b) Name two sensors that could be used in this intruder detection system. Give a reason for
your choice.
Sensor 1 ...................................................................................................................................
Reason .....................................................................................................................................
...................................................................................................................................................
Sensor 2 ...................................................................................................................................
Reason .....................................................................................................................................
...............................................................................................................................................[4]
The intruder system is set up so that the alarm will only sound if two or more sensors have been
triggered.
An assembly language program has been written to process the contents of the memory location.
The table shows part of the instruction set for the processor used.
Instruction
Explanation
Op code Operand
Direct addressing. Load the contents of the given address to
LDD <address>
ACC
STO <address> Store the contents of ACC at the given address
INC <register> Add 1 to the contents of the register (ACC or IX)
ADD <address> Add the contents of the given address to the contents of ACC
Bitwise AND operation of the contents of ACC with the
AND <address>
contents of <address>
CMP #n Compare the contents of ACC with the number n
JMP <address> Jump to the given address
Following a compare instruction, jump to <address> if the
JPE <address>
compare was True
Following a compare instruction, jump to <address> if the
JGT <address> content of ACC is greater than the number used in the
compare instruction
END End the program and return to the operating system
Op code Operand
SENSORS: B00001010
COUNT: 0
VALUE: 1
LOOP: LDD SENSORS
AND VALUE
CMP #0
JPE ZERO
LDD COUNT
INC ACC
STO COUNT
ZERO: LDD VALUE
CMP #8
JPE EXIT
ADD VALUE
STO VALUE
JMP LOOP
EXIT: LDD COUNT
TEST: CMP …
JGT ALARM
(i) Dry run the assembly language code. Start at LOOP and finish when EXIT is reached.
[4]
.......................................................................................................................................[1]
(iii) The intruder detection system is improved and now has eight sensors.
Published
This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.
Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.
Cambridge will not enter into discussions about these mark schemes.
Cambridge is publishing the mark schemes for the May/June 2016 series for most Cambridge IGCSE®,
Cambridge International A and AS Level components and some Cambridge O Level components.
1 (a) Single line joining all four computers and file server 1
One “terminator” at each end 1
(b)
Statement True False
Computer C uses the IP address of 1
Computer A to indicate that the packet is
for Computer A.
Computer B can read the packet sent from 1
Computer C to Computer A.
The File server routes the packet to 1
Computer A.
2 (a) Examples:
Serial number A mark for
Certificate Authority that issued certificate each
CA digital signature correct
Name of company/organisation/individual/subject/owner owning data item –
Certificate
‘Subject’ public key
Period during which Certificate is valid // some relevant date Max 3
(ii) Public 1
The individual does not know the private key of the CA // the individual
only knows the public key of the CA // only the CA can decrypt the
packaged information 1
(iii) Private 1
‘Only’ the CA’s public key will allow decryption of the Certificate //
proving the certificate was issued by the CA 1
(iii) Examples:
Financial transaction 1
Legal document 1
Software distribution 1
Max 2
(ii) Examples:
Using virtual machine means execution of extra code // emulation of 1
some hardware …
4 (a)
File organisation method File access method
1
serial direct
sequential sequential 2
random 1
Max 3
(ii) Random 1
Real-time transaction processing 1
Requires fastest access to data 1
No need to search through records 1
Max 3
(iii) Serial 1
Each new record is appended 1
Transactions are recorded in chronological order 1
File re-organisation not required for each new record // no need for the
records to be sorted
Max 3
5 (a)
A B X
0 0 1
0 1 1
1
1 0 1
1 1 0
(b) (i)
S R Q Q
1 0 0 1
1
1 1 0 1 1
0 1 1 0 1
1
1 1 1 0
0 0 1 1
(ii) S=0R=0 1
Max 3
Max 1
(b) Examples:
Pressure … 1 – sensor
If intruder steps on sensor 1–
justification
Infra-red …
If beam cut by intruder Maximum
2 sensors
Motion / ultrasonic…
Detects any movement in an area
Contact / magnetic …
If door / window opened Max 4
(c) (i)
BITREG COUNT VALUE ACC Mark as
follows:
B00001010 0 1 B00001010
B00000000 1 mark for:
1
COUNT
2 2 column
B00001010
VALUE
B00000010 column
0
First two
1 1 values in
2 ACC
column
4 4
B00001010 Rest of
ACC
B00000000 column
4
8 8
B00001010
B00001000
1
2 2
8 Max 4
(ii) #1 1
(iii) CMP #8 1
CMP #128 1
Candidates should use this material in preparation for the examination. Candidates should attempt the
practical programming tasks using their chosen high-level, procedural programming language.
DC (NH/SG) 123568
© UCLES 2016 [Turn over
258
2
This material is intended to be read by teachers and candidates prior to the June 2016 examination for
9608 Paper 4.
Candidates will also benefit from using pre-release materials from previous examinations. These are
available on the teacher support site.
Reminders
The syllabus states:
• there will be questions on the examination paper which do not relate to this pre-release material
• you must choose a high-level programming language from this list:
• Visual Basic (console mode)
• Python
• Pascal / Delphi (console mode)
Note: A mark of zero will be awarded if a programming language other than those listed is used.
The practical skills covered in Paper 2 are a precursor to those required in Paper 4. It is therefore
recommended that the high-level programming language chosen for this paper is the same as that for
Paper 2. This allows for sufficient expertise to be acquired with the opportunity for extensive practice.
Declaration of variables
The syllabus document shows the syntax expected for a declaration statement in pseudocode.
It is appreciated that candidates who use Python as their chosen language will not be familiar with the
concept of declaring all variables with their data type before they are used.
However, answers using Python will be required, instead of a declaration statement, to include a
comment statement, documenting the identifier name with its intended data type.
The question will clarify this with a wording and answer layout such as:
Visual Basic and Pascal: You should include declaration statements for variables.
Python: You should show a comment statement for each variable used with its data type.
..........................................................................................................................................
..........................................................................................................................................
An algorithm written in pseudocode requires that all variables have been identified. This may not be
the case if the initial attempt at the algorithm design is in structured English. The candidate will then be
required to identify the variables from the question.
A JSP data structure diagram is used to represent the data used by a problem.
Task 1
1.1 This symbol is used in a JSP data structure diagram. What is it used to represent?
A B C
1.3 Which are the three true statements for the JSP data structure diagram shown below?
A B C
1.5 This symbol is used in a JSP data structure diagram. What is it used to represent?
• sequence
• selection
• a procedure
• iteration
Task 2
A train, Train, consists of an engine, Engine, followed by a carriage, Carriage. Sometimes there is
a second Engine at the rear of the train.
Task 4
4.1 This symbol is used in a JSP data structure diagram. What is it used to represent?
4.2 A Train consists of an Engine followed by one or more Carriages. Sometimes there is a
second Engine at the rear of the train.
Key focus:
Draw the JSP data structure diagram. Using ‘iteration’ …
4.3 An examination paper, ExamPaper, consists of a front page, Front, followed by at least one
question, Question.
Task 5
A shipping company has a number of merchant ships. Data are recorded for all the voyages made by
each ship.
• a file header, FileHeader, which shows the date the file was last updated
• a file body, FileBody, which contains data for all the ships
• a file trailer, FileTrailer, which marks the end of the file
The data for each ship are made up of the name of the ship followed by the data records for each
voyage made. There may be a ship record for a ship which has not made any voyages so far.
ShipFile 1
*
Ship 3
*
ShipName ShipVoyage 4
2 the file is made up of the sequence of data components stated in the bulleted list above the
diagram.
Note:
• A component which has no derived lower level component(s) is called an elementary component.
FileHeader and FileTrailer are both elementary components.
• It may have been tempting to have the iterated data item Ship one line above (which would seem
to avoid the use of the FileBody item. However, this would have resulted in a sequence of ‘mixed-
type components’ at the same level. This must always be avoided.
3 The component Ship is an iteration, as it consists of the data for several ships.
4 We have ‘mixed-type components’ at the same level. That is ShipName (elementary) and
ShipVoyage (iterated). The solution therefore is the same as earlier. This gives the final diagram
below:
ShipFile
*
Ship
ShipName ShipBody
*
ShipVoyage
Key focus:
A data structure
Task 6 diagram for output
A JSP data structure diagram can also be used to describe the data requirements for a printed report.
A report, Report, is made up of a number of pages, Page. Each page consists of a possible heading,
Heading, followed by a number of lines, Line.
Logic Programming
Key focus:
Task 7 Lists
Logic programming can use a data structure called a list. The list items are enclosed inside square
brackets. Each item is separated by a comma. The list can be given an identifier name.
[budapest,paris,london,singapore,dhaka,oslo,brussels,amsterdam,cairo]
Example:
• X = budapest
• Y = [paris,london,singapore,dhaka,oslo,brussels,amsterdam,cairo]
Note:
The head is always a list item
The tail is always a list
Predicates can be defined and used to manipulate and interrogate a list.
Assume the predicate isEmpty is defined in the knowledge base to return TRUE or FALSE.
Example:
7.1
A = ......................................................................................
B = ......................................................................................
7.2
[kingston,rome,riga|C] = [kingston,rome,riga,bangkok,minsk]
C = ......................................................................................
7.3
[suva,stanley] = [D,E|F]
F = ......................................................................................
removeAndCompare(A,B,C)
Remove any elements from list A which are also present in list B.
Compare the amended list A with list C.
If the lists are identical, the predicate returns TRUE, otherwise returns FALSE.
7.4.1
removeAndCompare([moscow,ottowa,monaco],
[monaco,london],
[moscow,ottowa,monaco])
What is returned by this predicate?
......................................................................................
7.4.2
removeAndCompare([orange,banana],[ ],[orange,banana])
......................................................................................
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
No marks will be awarded for using brand names of software packages or hardware.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
DC (LM/SG) 124303
© UCLES 2016 [Turn over
268
2
1 A linked list abstract data type (ADT) is to be used to store and organise surnames.
This will be implemented with a 1D array and a start pointer. Elements of the array consist of a
user-defined type. The user-defined type consists of a data value and a link pointer.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
Write the pseudocode declaration statement for SurnameList. The lower and upper
bounds of the array are 1 and 5000 respectively.
.......................................................................................................................................[2]
(b) The following surnames are organised as a linked list with a start pointer StartPtr.
StartPtr: 3
1 2 3 4 5 6 5000
Surname Liu Yang Chan Wu Zhao Huang …
Ptr 4 5 6 2 0 1 …
(c) Pseudocode is to be written to search the linked list for a surname input by the user.
Complete the table above by adding the missing identifier details. [2]
01 Current ← ..............................................................................................................
02 IF Current = 0
03 THEN
04 OUTPUT .........................................................................................................
05 ELSE
06 IsFound ← .................................................................................................
07 INPUT ThisSurname
08 REPEAT
09 IF ............................................................................. = ThisSurname
10 THEN
11 IsFound ← TRUE
12 OUTPUT "Surname found at position ", Current
13 ELSE
14 // move to the next list item
15 .....................................................................................................
16 ENDIF
17 UNTIL IsFound = TRUE OR .....................................................................
18 IF IsFound = FALSE
19 THEN
20 OUTPUT "Not Found"
21 ENDIF
22 ENDIF
[6]
...........................................................................................................................................
.......................................................................................................................................[1]
(ii) Write the line number from the pseudocode shown in part (b) that shows the
An array MyList is used to store a sorted data set of non-zero integers. Unused cells contain
zero.
1 2 3 4 5 6 7 8 9 10
MyList 3 5 8 9 13 16 27 0 0 0
(i) Complete the trace table for the dry-run of the pseudocode for the procedure
CALL X(1, 9).
MyList
Index Item 1 2 3 4 5 6 7 8 9 10
1 9 3 5 8 9 13 16 27 0 0 0
[4]
(ii) State the purpose of procedure X when used with the array MyList.
...........................................................................................................................................
.......................................................................................................................................[1]
3 A car hire company hires cars to customers. Each time a car is hired, this is treated as a transaction.
• customer name
• ID number
• car registration
• hire start date
• number of days hired
The transaction data are stored in a text file HIRE-TRANS. The file is made up of a file body,
F_BODY, and a file trailer, F_TRAILER.
(a) The first step in Jackson Structured Programming (JSP) design is to produce a JSP data
structure diagram.
HIRE-TRANS
F_BODY
[7]
© UCLES 2016 9608/42/M/J/16
273
7
One report is CAR_REPORT. This displays all hire data for all cars.
CAR_REPORT
*
CAR
HIRE_LIST
HIRE
[5]
4 When a car reaches a certain age, a safety assessment has to be carried out. A car’s brakes and
tyres must be tested. The tyre test result and the brakes test result for each car are recorded. If the
car passes the assessment, a safety certificate is issued.
01 car(a05).
02 car(h04).
03 car(a03).
04 car(h07).
05 car(a23).
06 car(p05).
07 car(b04).
08 carRegYear(a05, 2015).
09 carRegYear(h04, 2013).
10 carRegYear(a03, 2008).
11 carRegYear(h07, 2011).
12 carRegYear(a23, 2008).
13 carRegYear(p05, 2014).
14 carRegYear(b04, 2014).
15 testBrakes(h07, pass).
16 testTyres(h07, fail).
17 testBrakes(a03, fail).
18 testTyres(a03, fail).
19 testBrakes(a23, pass).
20 testTyres(a23, pass).
21 carAssessmentDue if carRegYear(Car, RegYear)
and RegYear <= DeadlineYear.
22 issueCertificate(Car) if testTyres(Car, Result) and
testBrakes(Car, Result) and Result = pass.
Identify the car registrations for cars which are due to be tested.
.......................................................................................................................................[1]
(ii) State how clause 22 determines whether or not a safety certificate will be issued.
...........................................................................................................................................
.......................................................................................................................................[1]
retestAllowed(..............................) if ............................................................................
...................................................................................................................................................
...............................................................................................................................................[3]
23 carList = [a03,p05,b04,h04,h07,a23].
A = ......................................................................................
B = ...................................................................................... [2]
C = ..................................................................................... [1]
F = ..................................................................................... [1]
(d) The predicate conCatCompare is defined as a rule and returns TRUE or FALSE as follows:
conCatCompare(X, Y, Z)
Concatenates the lists X and Y and compares the new list with
list Z.
conCatCompare(X, Y, [a7,b6,c4])
If:
X = .................................................................................................................................[1]
5 (a) A program calculates the exam grade awarded from a mark input by the user. The code is
written as a function CalculateGrade.
The function:
Mark Grade
Under 40 FAIL
40 and over and under 55 PASS
55 and over and under 70 MERIT
70 and over DISTINCTION
(ii) State why this table design is suitable for black box testing.
...........................................................................................................................................
.......................................................................................................................................[1]
(b) When designing and writing program code, explain what is meant by:
• an exception
• exception handling
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[3]
(c) A program is to be written to read a list of exam marks from an existing text file into a 1D array.
Each line of the file stores the mark for one student.
State three exceptions that a programmer should anticipate for this program.
1 ................................................................................................................................................
...................................................................................................................................................
2 ................................................................................................................................................
...................................................................................................................................................
3 ................................................................................................................................................
...............................................................................................................................................[3]
29
30 ENDTRY
First number...53
Second number...6
Arithmetic operation resulted in an overflow
(i) State the pseudocode line number which causes the exception to be raised.
................................................... [1]
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
© UCLES 2016 9608/42/M/J/16 [Turn over
280
14
6 In a board game, one player has white pieces and the other player has black pieces. Players take
alternate turns to move one of their pieces. White always makes the first move.
• a player is unable to make a move when it is their turn. In this case, there is no winner. This is
called ‘stalemate’.
• a player wins the game as a result of their last move and is called a ‘winner’.
WHITE
WINS
No move
:+,7(·6 possible
TURN
Stalemate
BLACK moves
%/$&.·6 BLACK
TURN WINS
Winning
move
[4]
(b) The layout of the board at the start of the game is shown below:
x
y 1 2 3 4 5 6 7 8
1
8
© UCLES 2016 9608/42/M/J/16
281
15
The programmer decides to use a 2D array to represent the board. The index numbering to
be used is as shown.
Each square on the board is either occupied by one piece only, or is empty.
The data stored in the array indicate whether or not that square is occupied, and if so, with a
black piece or a white piece.
(i) Write program code to initialise the contents of the array to represent the board at the
start of the game. Use characters as follows for each square:
Visual Basic and Pascal: You should include the declaration statements for variables.
Python: You should show a comment statement for each variable used with its data type.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[4]
© UCLES 2016 9608/42/M/J/16 [Turn over
282
16
(ii) When a piece is to be moved, a procedure will calculate and output the possible
destination squares for the moving piece.
A piece can move one or more squares, in the x or y direction, from its current position.
For example, for the circled black piece there are nine possible destination squares. Each
of the two destination squares contains a white piece which would be removed.
x
y 1 2 3 4 5 6 7 8
The program requires a procedure ValidMoves.
1
Write program code for procedure ValidMoves with the following procedure header:
Visual Basic and Pascal: You should include the declaration statements for variables.
Python: You should show a comment statement for each variable used with its data type.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
© UCLES 2016 9608/42/M/J/16 [Turn over
284
18
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[5]
(i) Describe how classes and objects could be used in this problem.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
(ii) For a class you identified in part(c)(i), state two properties and two methods.
Class ..............................................
Properties
1 ........................................................................................................................................
2 ........................................................................................................................................
Methods
1 ........................................................................................................................................
2 ........................................................................................................................................
[2]
Published
This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.
Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.
Cambridge will not enter into discussions about these mark schemes.
Cambridge is publishing the mark schemes for the May/June 2016 series for most Cambridge IGCSE®,
Cambridge International A and AS Level components and some Cambridge O Level components.
Q estio
Qu on A
An
nsw
werr Mark
ks
1 (a)) (i)
( TY
YPE
E Lin
L nk
ked
dLi
ist
t 1 3
(D
DEC
CLA
ARE
E) S
Sur
rna
ame
e : ST
TRIING
G 1
(D
DEC
CLA
ARE
E) P
Ptr I TE
r : IN EGE
ER
EN
NDT
TYP
PE 1
Ac
cce
eptt:
Li
ink dList : RE
ked ECO
ORD 1
Su
urn me : S
nam STR
RIN
NG 1
tr : IN
Pt NTEG
GER
R
EN
NDR
REC
COR
RD
D 1
Ac
cce
eptt:
TY
YPE
E Lin
L nkked
dLi
ist
t = RE
ECO
ORD
D 1
Su
urn
nam
me : S
STR
RIN
NG 1
tr : IN
Pt NTEG
GER
R
EN
NDT
TYP
PE / E
END
DRE
ECO
ORD 1
Ac
cce
eptt:
ST
TRU
UCT
TUR RE L
Lin
nke
edL
List
t 1
(D
DEC
CLA
ARE
E) S
Sur
rna
ame
e : ST
TRIING
G 1
(D
DEC
CLA
ARE
E) P
Ptr I TE
r : IN EGE
ER
EN
NDS RUCTUR
STR RE 1
Accce
ept AS OF in
S / O nste
ead o
of :
(iii) (D
DEC
CLA E) S
ARE Sur
rna
ame
eLis
st[
[1:
:50
000
0] : Lin
L nke
edL
List
t 2
Accce
ept AS
S / O OF innsteead o
of :
Accce
ept () instteaad of []
ept witho
Accce outt lowe
er bou
b undd
Ind
dexx sep
s para
ato
or can
c n bee , : ...
(b)) (i)
( Wu
u 1
Accce
ept with quote
es
(iii) 6 1
(c)) (i)
( Is
sFo nd + relevantt descrip
oun ptio
on 1 2
BO
OOL
LEA
AN 1
© Ca
amb
brid
dge
e In
nterrnattion
nal Ex
xam
mina
atio
ons
s 20
016
6
288
Page 3 Mark Scheme Syllabus Paper
Cambridge International A Level – May/June 2016 9608 42
2 (a) (i) A procedure which is defined in terms of itself // A procedure which makes a call to 1
itself // A procedure that calls itself
(ii) 08 // 8 1
1 9 3 5 8 9 13 16 27 0 0 0
13
4
5 16
6 27
7 0
3 (a) 7
HIRE-TRANS
F_BODY F_TRAILER
TRANS
Customer
data Hire data
Mark as follows:
Label F_TRAILER 1
Label TRANS 1
(b) 5
Mark as follows:
Selection symbol x 2 (Car-hire / No car-hire) 1
Labelling for CAR_HIRE / NO_HIRE (accept similar labels*) 1
Labelling for Car registration and Car total / Total hires 1
Iteration symbol for HIRE (accept in HIRE_LIST as a BOD) 1
Labelling for start date and number of days (as per diagram) 1
(ii) The car must pass (both) brake test and tyres test 1
(b) retestAllowed(ThisCar) 3
1
If (testBrakes(ThisCar, pass) and testTyres(ThisCar, fail))
1
or (testBrakes(ThisCar, fail) and testTyres(ThisCar, pass))
1
(one mark per bold underlined all correct)
accept another variable instead of ThisCar, but must be same throughout.
must be []
must be lower case, but don’t penalise twice, so follow through from part(b)
(ii) [p05,m04] 1
(iii) [ ] 1
(d) [ ] 1
Normal FAIL/PASS/MERIT/DISTINCTION
Abnormal Error
Extreme/Boundary FAIL/PASS/MERIT/DISTINCTION
(ii) (The programmer is) concerned only with the input (i.e. the mark) to the function and 1
monitoring the expected output (i.e. the grade)
// can compare expected result and actual result
(b) Exception: 3
1. situation causing a crash / run-time error / fatal error 1
Exception handling:
2. code which is called when a run-time error occurs 1
3. … to avoid the program terminating/crashing 1
(d) (i) 09 // 9 1
6 (a) 4
BOARD class:
Properties:
• Number of squares / size / dimensions
• Current state of all squares
Methods: –
• Set the starting board
• Capture the finishing state of the board
• Display the state of the board after each move
PIECE class:
Properties:
• Starting x position
• Starting y position
• Current x position
• current y position
• Colour
• State / Removed / Active
Methods:
• Move piece
• Remove piece
Mark as follows:
two correct responses are worth 1 mark
Programming code
6 (b) (i)
VB.NET
Dim Board(8, 8) As Char
Dim Row, Column As Integer
For Row = 1 To 2
For Column = 1 To 8
Board(Row, Column) = "B"
Next
Next
For Row = 3 To 6
For Column = 1 To 8
Board(Row, Column) = "E"
Next
Next
For Row = 7 To 8
For Column = 1 To 8
Board(Row, Column) = "W"
Next
Next
PASCAL
var Row, Column : integer;
Board : array[1..8, 1..8] of char;
begin
for Row := 1 to 2 do
for Column := 1 to 8 do
Board[Row, Column] := 'B';
for Row := 3 to 6 do
for Column := 1 to 8 do
Board[Row, Column] := 'E';
for Row := 7 to 8 do
for Column := 1 to 8 do
Board[Row, Column] := 'W';
end.
PYTHON
Board = [["" for j in range(9)] for i in range(9)]
for Row in range(1, 3) :
for Column in range(1, 9) :
Board[Row][Column] = "B"
for Row in range(3, 7) :
for Column in range(1, 9) :
Board[Row][Column] = "E"
for Row in range(7, 9) :
for Column in range(1, 9) :
Board[Row][Column] = "W"
Board = [[]]
for i in range(9) :
for j in range(9) :
Board.append("")
Instead of initialising with empty string, could initialise with ‘E’. this would then only require ‘B’ and ‘W’
loops later.
For example:
Board =[]
for i in range(9):
Board.append(["E"]*9)
6 (b) (ii)
VB.NET
Sub ValidMoves(ByVal PieceColour As Char, ByVal xCurrent As Integer,
ByVal yCurrent As Integer)
Dim i As Integer
Dim StopperColour As Char
Dim NoFurther As Boolean
If PieceColour = "B" Then
StopperColour = "W"
Else
StopperColour = "B"
End If
Console.WriteLine("Possible moves are : ")
If xCurrent <> 1 Then
Console.WriteLine("Moving LEFT . . .")
i = xCurrent – 1
NoFurther = False
do
if Board(i, yCurrent) = "E" Then
Console.WriteLine(i & " " & yCurrent)
End If
if Board(i, yCurrent) = StopperColour Then
Console.WriteLine(i & " " & yCurrent & " REMOVE PIECE")
NoFurther = True
End If
i = i – 1
Loop Until i = 0 Or NoFurther = True
End If
if xCurrent <> 8 Then
Console.WriteLine("Moving RIGHT . . .")
i = xCurrent + 1
NoFurther = False
do
if Board(i, yCurrent) = "E" :
Console.WriteLine(i & " " & yCurrent)
End If
if Board(i, yCurrent) = StopperColour Then
Console.WriteLine(i & " " & yCurrent & " REMOVE PIECE")
NoFurther = True
End If
i = i + 1
Loop Until i = 9 Or NoFurther = True
End If
End Sub
PASCAL
procedure ValidMoves(PieceColour : char; xCurrent, yCurrent : integer);
var StopperColour : char;
i : integer;
NoFurther : boolean;
begin
if (PieceColour = 'B') then
StopperColour := 'W'
else
StopperColour := 'B';
writeln('Possible moves are : ');
if (xCurrent <> 1) then
begin
writeln('Moving LEFT . . . ');
i := xCurrent – 1;
NoFurther := false;
repeat
if (Board[i, yCurrent] = 'E') then
writeln(intToStr(i) + ' ' + intToStr(yCurrent));
if (Board[i, yCurrent] = StopperColour) then
begin
writeln(intToStr(i) + ' ' + intToStr(yCurrent) + ' REMOVE
PIECE');
NoFurther := true;
end;
i := i – 1;
until ((i = 0) or (NoFurther = true));
end;
if (xCurrent <> 8) then
begin
writeln('Moving RIGHT . . . ');
i := xCurrent + 1;
NoFurther := false;
repeat
if (Board[i, yCurrent] = 'E') then
writeln(intToStr(i) + ' ' + intToStr(yCurrent));
if (Board[i, yCurrent] = StopperColour) then
begin
writeln(intToStr(i) + ' ' + intToStr(yCurrent) + ' REMOVE
PIECE');
NoFurther := true;
end;
i := i + 1;
until ((i = 9) or (NoFurther = true));
end;
end;
PYTHON
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
DC (NF/AR) 116626/4
© UCLES 2016 [Turn over
302
2
1 In a particular computer system, real numbers are stored using floating-point representation with:
(a) Calculate the floating-point representation of + 2.5 in this system. Show your working.
Mantissa Exponent
•
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [3]
(b) Calculate the floating-point representation of − 2.5 in this system. Show your working.
Mantissa Exponent
•
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [3]
(c) Find the denary value for the following binary floating-point number. Show your working.
Mantissa Exponent
0
•0 1 1 0 0 0 0 0 0 0 0 0 0 1 1
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [3]
(d) (i) State whether the floating-point number given in part (c) is normalised or not normalised.
...................................................................................................................................... [1]
...........................................................................................................................................
...................................................................................................................................... [1]
(e) The system changes so that it now allocates 8 bits to both the mantissa and the exponent.
State two effects this has on the numbers that can be represented.
1 ...............................................................................................................................................
...................................................................................................................................................
2 ...............................................................................................................................................
.............................................................................................................................................. [2]
2 There are four stages in the compilation of a program written in a high-level language.
(a) Four statements and four compilation stages are shown below.
[4]
(b) Write the Reverse Polish Notation (RPN) for the following expressions.
(i) (A + B) * (C − D)
...................................................................................................................................... [2]
(ii) − A / B * 4 / (C − D)
...................................................................................................................................... [3]
(c) An interpreter is executing a program. The program uses the variables w, x, y and z.
The program contains an expression written in infix form. The interpreter converts the infix
expression to RPN. The RPN expression is:
x w z + y − *
w = 1 x = 2 y = 3 z = 4
(i) Show the changing contents of the stack as the interpreter evaluates the expression.
The first entry on the stack has been done for you.
[4]
(ii) Convert back to its original infix form, the RPN expression:
x w z + y − *
...........................................................................................................................................
...................................................................................................................................... [2]
(iii) Explain one advantage of using RPN for the evaluation of an expression.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
In paging:
135 0 0
When a particular page of the process is currently in main memory, the Presence flag entry in the
page table is set to 1.
If the page is not currently present in memory, the Presence flag is set to 0.
.............................................................................................................................................. [1]
(b) Process X executes until the next instruction is the first instruction in Page 4. Page 4 is not
currently in main memory.
.............................................................................................................................................. [1]
(c) When an instruction to be accessed is not present in main memory, its page must be loaded
into a page frame. If all page frames are currently in use, the contents of a page frame will be
overwritten with this new page.
One possible algorithm is to replace the page that has been resident in main memory for the
longest time.
(i) Give the additional data that would need to be stored in the page table.
...........................................................................................................................................
..................................................................................................................................... [1]
(ii) Complete the table entries below to show what happens when Page 4 is swapped into
main memory. Assume that Page 5 is the one to be replaced.
In the final column, give an example of the data you have identified in part (c)(i).
4
............... .................... .....................................
[3]
An alternative algorithm is to replace the page that has been used least.
(iii) Give the different additional data that the page table would now need to store.
...........................................................................................................................................
...................................................................................................................................... [1]
(iv) In the following table, complete the missing data to show what happens when Page 3 is
swapped into main memory. Assume that Page 1 is the one to be replaced.
In the final column, give an example of the data you have identified in part (c)(iii).
3
............... .................... .....................................
[3]
© UCLES 2016 9608/31/O/N/16 [Turn over
308
8
(d) Explain why the algorithms given in part (c) may not be the best choice for efficient memory
management.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [4]
4 (a) (i) Complete the truth table for this logic circuit.
X Input Output
A X Y A B
Y 0 0
0 1
1 0
B 1 1
[2]
...................................................................................................................................... [1]
Label A ..............................................................................................................................
Label B ..............................................................................................................................
Explain why your answers are more appropriate for the A and B labels.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [4]
(b) (i) Write the Boolean expression corresponding to the following logic circuit:
B
X
...................................................................................................................................... [2]
(ii) Use Boolean algebra to simplify the expression that you gave in part (b)(i).
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [3]
5 The TCP/IP protocol suite can be viewed as a stack with four layers.
(a) (i) Complete the stack by inserting the names of the three missing layers.
Transport
[3]
...................................................................................................................................... [1]
(i) Describe two tasks that the Transport layer performs to ensure that the incoming data is
downloaded correctly.
1 .......................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
2 .......................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [4]
...................................................................................................................................... [1]
...................................................................................................................................... [1]
Description Term
Malware that attaches itself to another program.
(b) Ben wants to send a highly confidential email to Mariah so that only she can read it. Plain text
and cipher text will be used in this communication.
...........................................................................................................................................
...................................................................................................................................... [2]
(ii) Explain how the use of asymmetric key cryptography ensures that only Mariah can read
the email.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [4]
Published
This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.
Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.
Cambridge will not enter into discussions about these mark schemes.
Cambridge is publishing the mark schemes for the October/November 2016 series for most
®
Cambridge IGCSE , Cambridge International A and AS Level components and some Cambridge O Level
components.
1 (a) +2.5
= 010100000000 0010 [3]
Give full marks for correct answer (normalised or not normalised)
= 10.1 [1]
= 0.101 × 22 // evidence of shifting binary point appropriately [1]
[Max 3]
(b) –2.5
101100000000 0010
Give full marks for correct answer
[Max 3]
(c) 3 [3]
Give full marks for correct answer
[Max 3]
© UCLES 2016
314
Page 3 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 31
2 (a)
Statement Compilation stage
1 mark
This stage could be ignored Syntax analysis
for each
correct
This stage checks the line
grammar of the program Code generation
code
(ii) A – [1]
B/4* [1]
CD–/ [1]
(c) (i)
4 3
1
1 1 5 5 2 mark
per ring
2 2 2 2 2 2 4
+ – *
[4]
(ii) x * [1]
(w + z – y) [1]
Order must be correct for both parts
[Max 2]
© UCLES 2016
315
Page 4 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 31
(ii)
Page Presence Page frame Additional data
Flag address
4 1 542 12:07:34:49 [1 +1 + 1]
(iv)
Page Presence Page frame Additional data
Flag address
3 1 132 0 [1 +1 + 1]
Least used: a page just entered has a low least used value … [1]
so likely to be a candidate for immediately being swapped out [1]
© UCLES 2016
316
Page 5 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 31
4 (a) (i)
Input Output
X Y A B
0 0 0 0 1 mark for each
correct column
0 1 0 1 (A and B)
1 0 0 1
1 1 1 0
[2]
A.(A.B+C)
= A.A.B + A.C
= A.B +A.C
= A.(B+C)
© UCLES 2016
317
Page 6 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 31
5 (a) (i)
Application [1]
Transport
Internet [1]
[Max 2 tasks]
[Max 4]
© UCLES 2016
318
Page 7 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 31
6 (a)
Description Term
(ii) Asymmetric keys means that the key used to encrypt (public key) is different from the
key used to decrypt (private key) [1]
Ben acquires Mariah’s public key [1]
Ben encrypts email … [1]
using Mariah’s public key [1]
Ben sends encrypted email to Mariah [1]
Mariah decrypts email … [1]
Using her private key [1]
[Max 4]
© UCLES 2016
319
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
DC (ST/JG) 116627/3
© UCLES 2016 [Turn over
320
2
1 In a particular computer system, real numbers are stored using floating-point representation with:
(a) Calculate the floating point representation of + 3.5 in this system. Show your working.
Mantissa Exponent
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [3]
(b) Calculate the floating-point representation of –3.5 in this system. Show your working.
Mantissa Exponent
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [3]
(c) Find the denary value for the following binary floating-point number. Show your working.
Mantissa Exponent
0 1 1 1 0 0 0 0 0 0 0 0 0 1 0 0
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [3]
(d) (i) State whether the floating-point number given in part (c) is normalised or not normalised.
...................................................................................................................................... [1]
...........................................................................................................................................
...................................................................................................................................... [1]
(e) Give the binary two’s complement pattern for the negative number with the largest magnitude.
Mantissa Exponent
[2]
2 There are four stages in the compilation of a program written in a high-level language.
(a) Four statements and four compilation stages are shown below.
[4]
(b) Write the Reverse Polish Notation (RPN) for the following expression.
P + Q – R / S
.............................................................................................................................................. [2]
(c) An interpreter is executing a program. The program uses the variables a, b, c and d.
The program contains an expression written in infix form. The interpreter converts the infix
expression to RPN. The RPN expression is:
b a * c d a + + -
a = 2 b = 2 c = 1 d = 3
(i) Show the changing contents of the stack as the interpreter evaluates the expression.
The first entry on the stack has been done for you.
2
[4]
(ii) Convert back to its original infix form, the RPN expression:
b a * c d a + + -
...........................................................................................................................................
...................................................................................................................................... [2]
(iii) One advantage of using RPN is that the evaluation of an expression does not require
rules of precedence.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
In paging:
249 0 0
1 ................................................................................................................................................
...................................................................................................................................................
2 ................................................................................................................................................
.............................................................................................................................................. [2]
(b) Process Y executes the last instruction in Page 5. This instruction is not a branch instruction.
(i) Explain the problem that now arises in the continued execution of process Y.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
© UCLES 2016 9608/32/O/N/16
325
7
(ii) Explain how interrupts help to solve the problem that you explained in part (b)(i).
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [3]
(c) When the next instruction is not present in main memory, the OS must load its page into a
page frame. If all page frames are currently in use, the OS overwrites the contents of a page
frame with the required page.
One possible algorithm is to replace the page which has been in memory the shortest amount
of time.
(i) Give the additional data that would need to be stored in the page table.
...........................................................................................................................................
...................................................................................................................................... [1]
(ii) Complete the table entry below to show what happens when Page 6 is swapped into
main memory. Include the data you have identified in part (c)(i) in the final column.
Assume that Page 1 is the one to be replaced.
In the final column, give an example of the data you have identified in part (c)(i).
[3]
Process Y contains instructions that result in the execution of a loop, a very large number of
times. All instructions within the loop are in Page 1.
The loop contains a call to a procedure whose instructions are all in Page 3.
All page frames are currently in use. Page 1 is the page that has been in memory for the
shortest time.
(iii) Explain what happens to Page 1 and Page 3, each time the loop is executed.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [3]
...................................................................................................................................... [1]
4 Both clients and servers use the Secure Socket Layer (SSL) protocol and its successor, the
Transport Layer Security (TLS) protocol.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
...................................................................................................................................... [1]
...................................................................................................................................... [1]
(iv) Identify two problems that the SSL and TLS protocols can help to overcome.
1 ........................................................................................................................................
2 ................................................................................................................................... [2]
© UCLES 2016 9608/32/O/N/16
327
9
(b) Before any application data is transferred between the client and the server, a handshake
process takes place. Part of this process is to agree the security parameters to be used.
1 ................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
2 ................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [4]
(c) Name two applications of computer systems where it would be appropriate to use the SSL or
TLS protocol. These applications should be different from the ones you named in part (a)(ii)
and part (a)(iii).
1 ................................................................................................................................................
...................................................................................................................................................
2 ................................................................................................................................................
.............................................................................................................................................. [2]
5 (a) (i) A half adder is a logic circuit with the following truth table.
Input Output
X Y A B
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 0
P X A
J
HALF ADDER
Q Y B
X A
HALF ADDER
R Y B K
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
[2]
...................................................................................................................................... [1]
Label J ..............................................................................................................................
Label K ..............................................................................................................................
Explain why your answers are appropriate labels for these outputs.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [4]
(b) (i) Write down the Boolean expression corresponding to the following logic circuit:
A
B
X
...................................................................................................................................... [2]
(ii) Use Boolean algebra to simplify the expression given in part (b)(i).
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [4]
6 A Local Area Network (LAN) consists of four computers, one server and a switch. The LAN uses a
star topology.
(a) Complete the diagram below to show how to connect the devices.
(c) In the same building as this star network, there is another star network.
(i) Name the device needed to connect the two networks together.
...................................................................................................................................... [1]
(ii) Explain how the device in part (c)(i) decides whether to transfer a packet from one
network to the other.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.
Published
This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.
Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.
Cambridge will not enter into discussions about these mark schemes.
Cambridge is publishing the mark schemes for the October/November 2016 series for most
®
Cambridge IGCSE , Cambridge International A and AS Level components and some Cambridge O Level
components.
1 (a) +3.5
01110000 00000010 [3]
Give full marks for correct answer (normalised or unnormalised)
= 11.1 [1]
= 0.111 × 22 // evidence of shifting binary point appropriately [1]
[Max 3]
(b) –3.5
10010000 00000010 [3]
3 marks for correct answer
One’s complement of 8-bit mantissa for +3.5 10001111 – allow f.t. [1]
+1 to get two’s complement 10010000 [1]
[Max 3]
(c) 14 [3]
3 marks for correct answer
[Max 3]
(e)
[1]
1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1
[1]
© UCLES 2016
333
Page 3 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 32
2 (a)
Statement Compilation stage
1
This stage produces
Syntax analysis mark for
object code.
each
correct
line
This stage makes use
Code generation
of tree data structures.
(b) P Q + [1]
RS/ – [1]
(c) (i)
2
3 3 5
1
2 1 1 1 1 6 mark
per ring
2 2 4 4 4 4 4 4 –2
* + + –
[4]
(ii) b * a [1]
– (c + d + a) [1]
Order must be correct for both parts
(iii) Rules of precedence means different operators have different priorities // by example
multiply is done before add [1]
In RPN evaluation of operators is left to right // operators are used in the sequence in
which they are read [1]
No need for brackets // infix may require the use of brackets [1]
[Max 2 ]
© UCLES 2016
334
Page 4 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 32
[Max 2]
(ii) When there is an attempt to load an instruction for a page not in memory [1]
A page fault occurs // Page 5 finishes … [1]
this generates an interrupt [1]
ISR code is executed [1]
Causes the OS to load page 6 into memory [1]
[Max 3]
(ii)
Page Presence Page frame address Additional data
Flag
6 1 221 12:07:34:49 [1 + 1 + 1]
(iii) When the procedure call is made – Page 1 is swapped out and Page 3 is swapped in [1]
At the end of the procedure call – Page 3 is swapped out and Page 1 is swapped in [1]
Page 1/3 is always in memory shortest amount of time [1]
The entire sequence is repeated for every iteration [1]
[Max 3]
© UCLES 2016
335
Page 5 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 32
[Max 2]
[Max 2 parameters]
[Max 4]
banking [1]
private / secure email [1]
shopping [1]
financial transactions [1]
secure file transfer [1]
[Max 2]
© UCLES 2016
336
Page 6 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 32
5 (a) (i)
Input Output
Working space
P Q R J K
0 0 0 0 0
0 0 1 0 1
1 mark each column
0 1 0 0 1
0 1 1 1 0 If zero marks then
6 or 7 pairs correct – 1 mark
1 0 0 0 1
1 0 1 1 0
1 1 0 1 0
1 1 1 1 1
[2]
A. ((A+B).C)
= A.(A.C + B.C)
= A.A.C +A.B.C
= A.C + A.B.C
= A.C (1 + B)
=A.C.1
= A.C
[4]
© UCLES 2016
337
Page 7 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 32
6 (a)
Computer A Computer B Server 4×
Computer to
Switch
[1]
Server to
Computer C Computer D Switch Switch
[1]
(b)
Statement True False
[Max 2]
© UCLES 2016
338
at the Centre.
Candidates should use this material in preparation for the examination. Candidates should attempt the
practical programming tasks using their chosen high-level, procedural programming language.
DC (ST) 115878/4
© UCLES 2016 [Turn over
339
2
Teachers and candidates should read this material prior to the November 2016 examination for
9608 Paper 4.
Reminders
The syllabus states:
• there will be questions on the examination paper which do not relate to this pre-release material
• you must choose a high-level programming language from this list:
• Visual Basic (console mode)
• Python
• Pascal / Delphi (console mode)
Note: A mark of zero will be awarded if a programming language other than those listed is used.
The practical skills for Paper 4 build on the practical skills for Paper 2. We therefore recommend that
candidates choose the same high-level programming language for this paper as they did for Paper 2.
This will give candidates the opportunity for extensive practice and allow them to acquire sufficient
expertise.
Declaration of variables
The syllabus document shows the syntax expected for a declaration statement in pseudocode.
If Python is the chosen language, each variable’s identifier (name) and its intended data type must be
documented using a comment statement.
TASK 1
When writing high-level language programs you are asked to use one of:
• Python
• Visual Basic (console mode)
• Pascal/Delphi (console mode) Key focus: Programming environments
Make sure you know the name of the programming environment that you use to write programs in your
chosen programming language.
TASK 1.1
Explore the features of your editor that help you to write program code.
When and how does your programming environment report syntax errors?
TASK 1.2
When you write program code, explore debugger features available to you and practise using them to
step through programs and explore the state of the variables after each instruction.
Explore how the debugger can help to find logic errors and run-time errors.
TASK 1.3
You will need to write a main program that initialises and populates an array of names to be sorted.
The program then calls the procedure Sort.
Decide on some test data. Write down the expected results after each repetition (iteration) of the FOR
loop. You should test your program with several different sets of data. Use the debugger each time to
step through the program.
Extension task
Explore what program libraries are available for your chosen programming language. How can you
make use of a library routine that is not part of the basic set-up of your programming environment?
TASK 2
The table shows part of the instruction set for a processor which has one general purpose register, the
Accumulator (ACC), and an index register (IX).
Note: These instructions are all referred to in syllabus sections 1.4.3 and 3.6.2.
Instruction
Op Explanation
Operand
code
LDM #n Immediate addressing. Load the number n to ACC
LDD <address> Direct addressing. Load the contents of the given address to ACC
Indirect addressing. The address to be used is at the given address. Load the
LDI <address>
contents of this second address to ACC
Indexed addressing. Form the address from <address> + the contents of the
LDX <address>
index register. Copy the contents of this calculated address to ACC
LDR #n Immediate addressing. Load the number n into IX
STO <address> Store the contents of ACC at the given address
ADD <address> Add the contents of the given address to the ACC
INC <register> Add 1 to the contents of the register (ACC or IX)
DEC <register> Subtract 1 from the contents of the register (ACC or IX)
JMP <address> Jump to the given address
CMP <address> Compare the contents of ACC with the contents of <address>
CMP #n Compare the contents of ACC with number n
JPE <address> Following a compare instruction, jump to <address> if the compare was TRUE
JPN <address> Following a compare instruction, jump to <address> if the compare was FALSE
AND #n Bitwise AND operation of the contents of ACC with the operand
AND <address> Bitwise AND operation of the contents of ACC with the contents of <address>
XOR #n Bitwise XOR operation of the contents of ACC with the operand
XOR <address> Bitwise XOR operation of the contents of ACC with the contents of <address>
OR #n Bitwise OR operation of the contents of ACC with the operand
OR <address> Bitwise OR operation of the contents of ACC with the contents of <address>
IN Key in a character and store its ASCII value in ACC
OUT Output to the screen the character whose ASCII value is stored in ACC
END Return control to the operating system
Notes:
Tasks 2.1 to 2.7 all use one of the following two formats for symbolic addressing.
Format Example
<label>: <op code> <operand> START: LDA #0
<label>: <data> NUM1: B01001010
Write assembly language program code using the instruction set provided on page 4.
TASK 2.1
X ← A + B
END
Instruction
Label Op Comment
Operand
code
START: // load the content of A into ACC
X:
A: 5
B: 3
TASK 2.2
IF X = A
THEN
OUTPUT CHR(X) // statements for THEN part
ELSE
A ←
A + 1 // statements for ELSE part
ENDIF
END
Instruction
Label Op Comment
Operand
code
START: // load the content of X into ACC
A: 65
X: 67
Note: the built-in function CHR(X) returns the character that is represented by the ASCII code held in X.
TASK 2.3
REPEAT
OUTPUT CHR(X)
X ← X - 1
UNTIL X = A
END
Instruction
Label Op Comment
Operand
code
LOOP: // instructions to be repeated start here
X: 90
A: 65
TASK 2.4
FOR COUNT ←
1 TO 4
OUTPUT CHARS[COUNT]
ENDFOR
END
Instruction
Label Op Comment
Operand
code
// set ACC to zero
// COUNT = 4 ?
COUNT:
CHARS: 72 // 'H'
69 // 'E'
76 // 'L'
80 // 'P'
TASK 2.5
WHILE X <> B
OUTPUT CHARS[B]
B ← B + 1
ENDWHILE
END
Instruction
Label Op Comment
Operand
code
LOOP: // load content of X into ACC
// is content of ACC = content of B ?
// if equal (TRUE) jump to ENDWHILE
// instructions to be repeated start here
X: 4
B: 0
CHARS: 72 // 'H'
69 // 'E'
76 // 'L'
80 // 'P'
TASK 2.6
Instruction
Address Op Comment
Operand
code
// use indirect addressing to load contents of
LOOP:
address found at address 100
// output character with ASCII code held in ACC
// increment ACC
100 102
101
102 77 // 'M'
103 65 // 'A'
104 84 // 'T'
105 72 // 'H'
106 83 // 'S'
107
TASK 2.7
Programmers use bitwise operations (AND, OR, XOR) to set or examine specific bits.
Example:
Instruction
Label Op Comment
Operand
code
LOOP: LDD X // load content of X into ACC
// bitwise AND operation on content of ACC and
AND MASK
content of MASK
STO Y // store content of ACC in Y
X: B10101111
MASK: B00000001
Write simple programs using the different bitwise operations (AND, OR, XOR) and different MASK content.
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every reasonable
effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the publisher will
be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.
Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
DC (ST/SW) 115877/3
© UCLES 2016 [Turn over
351
2
1 A user can lock a safety deposit box by inputting a 4-digit code. The user can unlock the box with
the same 4-digit code.
There is a keypad on the door of the safety deposit box. The following diagram shows the keys on
the keypad.
1 2 3
4 5 6
7 8 9
R 0 Enter
Initially, the safety deposit box door is open and the user has not set a code.
A) To set a new code the door must be open. The user chooses a 4-digit code and sets it by
pressing the numerical keys on the keypad, followed by the Enter key. Until the user clears
this code, it remains the same. (See point E below)
B) The user can only close the door if the user has set a code.
C) To lock the door, the user closes the door, enters the set code and presses the Enter key.
D) To unlock the door, the user enters the set code. The door then opens automatically.
E) The user clears the code by opening the door and pressing the R key, followed by the Enter
key. The user can then set a new code. (See point A above)
The following state transition table shows the transition from one state to another of the safety
deposit box:
.......................................................
start
............................
Door open
no code set
............................
......................................
...............................................
...............................................
Door closed
............................
............................
...............................................
...............................................
[7]
(b) A company wants to simulate the use of a safety deposit box. It will do this with object-oriented
programming (OOP).
The following diagram shows the design for the class SafetyDepositBox. This includes the
properties and methods.
SafetyDepositBox
Code : STRING // 4 digits
State : STRING // "Open-NoCode", "Open-CodeSet", "Closed"
// or "Locked"
Create() // method to create and initialise an object
// if using Python use __init__
Reset() // clears Code
SetState() // set state to parameter value
// and output new state
SetNewCode() // sets Code to parameter value
// output message and new code
StateChange() // reads keypad and takes appropriate action
(i) Create()
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [3]
(ii) Reset()
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
(iii) SetState()
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
(iv) SetNewCode()
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [4]
(vi) Convert the flowchart to program code for the method StateChange(). Use the
properties and methods in the original class definition and the Valid() function from
part (v).
METHOD StateChange
INPUT Chars
No No
CALL SetState("Open-NoCode")
No No
Is State = Yes
CALL SetState("Locked")
"Closed"?
No
No
No No
CALL SetState("Open-CodeSet")
OUTPUT "Error – OUTPUT "Error –
code format does not match
incorrect" set code"
ENDMETHOD
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.....................................................................................................................................[12]
(vii) The company needs to write a program to simulate a safety deposit box. The program
will create an object with identifier ThisSafe, which is an instance of the class
SafetyDepositBox.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [4]
The programmer has modified the class design for SafetyDepositBox as follows:
SafetyDepositBox
PRIVATE
Code : STRING
State : STRING
PUBLIC
Create()
StateChange()
PRIVATE
Reset()
SetState()
SetNewCode()
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
(ii) Describe the effects of declaring two methods of the class as public and the other three
as private.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
(a) (i) Name the programming environment you have used when typing in program code.
...........................................................................................................................................
...........................................................................................................................................
List three features of the editor that helped you to write program code.
1 ........................................................................................................................................
...........................................................................................................................................
2 ........................................................................................................................................
...........................................................................................................................................
3 ........................................................................................................................................
...................................................................................................................................... [3]
(ii) Explain when and how your programming environment reports a syntax error.
When .................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
How ...................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
(iii) The table shows a module definition for BinarySearch in three programming languages.
A B C
A) Python
01 def BinarySearch(List, Low, High, SearchItem):
02 Index = -1
03 while (Index == -1) AND (Low <= High):
04 Middle = (High + Low) // 2
05 if List[Middle] == SearchItem:
06 Index = Middle
07 elif List[Middle] < SearchItem:
08 Low = Middle + 1
09 else:
10 High = Middle - 1
11 return(Middle)
B) Pascal/Delphi
01 FUNCTION BinarySearch(VAR List : ARRAY OF INTEGER; Low, High,
SearchItem : INTEGER) : INTEGER;
02 VAR Index, Middle : INTEGER;
03 BEGIN
04 Index := -1;
05 WHILE (Index = -1) & (Low <= High) DO
06 BEGIN
07 Middle := (High + Low) DIV 2;
08 IF List[Middle] = SearchItem
09 THEN Index := Middle
10 ELSE IF List[Middle] < SearchItem
11 THEN Low := Middle + 1
12 ELSE High := Middle - 1;
13 END;
14 Result := Middle;
15 END;
C) Visual Basic
01 Function BinarySearch(ByRef List() As Integer, ByVal Low As Integer,
ByVal High As Integer, ByVal SearchItem As Integer) As Integer
02 Dim Index, Middle As Integer
03 Index = -1
04 Do While (Index = -1) & (Low <= High)
05 Middle = (High + Low) \ 2
06 If List(Middle) = SearchItem Then
07 Index = Middle
08 ElseIf List(Middle) < SearchItem Then
09 Low = Middle + 1
10 Else
11 High = Middle - 1
12 End If
13 Loop
14 BinarySearch = Middle
15 End Function
.......................................................................................................................................[2]
(b) (i) State whether programs written in your programming language are compiled or
interpreted.
...........................................................................................................................................
...................................................................................................................................... [1]
(ii) A programmer corrects the syntax error and tests the function. It does not perform as
expected when the search item is not in the list.
...........................................................................................................................................
.......................................................................................................................................[2]
(iii) State the programming environment you have used when debugging program code.
...........................................................................................................................................
...........................................................................................................................................
Name two debugging features and describe how they are used.
1 ........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
2 ........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [4]
3 The following table shows part of the instruction set for a processor which has one general purpose
register, the Accumulator (ACC), and an index register (IX).
Instruction
Op Explanation
Operand
code
LDM #n Immediate addressing. Load the number n to ACC.
LDD <address> Direct addressing. Load the contents of the given address to ACC.
Indexed addressing. Form the address from <address> + the contents
LDX <address> of the index register. Copy the contents of this calculated address to
ACC.
LDR #n Immediate addressing. Load the number n into IX.
STO <address> Store the contents of ACC at the given address.
INC <register> Add 1 to the contents of the register (ACC or IX).
DEC <register> Subtract 1 from the contents of the register (ACC or IX).
CMP <address> Compare the contents of ACC with the contents of <address>.
CMP #n Compare the contents of ACC with number n.
Following a compare instruction, jump to <address> if the compare
JPE <address>
was True.
Following a compare instruction, jump to <address> if the compare
JPN <address>
was False.
Output to the screen the character whose ASCII value is stored in
OUT
ACC.
END Return control to the operating system.
A programmer is writing a program that outputs a string, first in its original order and then in
reverse order.
The program will use locations starting at address NAME to store the characters in the string. The
location with address MAX stores the number of characters that make up the string.
The programmer has started to write the program in the table opposite. The Comment column
contains descriptions for the missing program instructions.
Complete the program using op codes from the given instruction set.
Op
Label Operand Comment
code
START: // initialise index register to zero
// is COUNT = MAX ?
// store in COUNT
// is COUNT = MAX ?
// end of program
COUNT:
MAX: 4
[15]
© UCLES 2016 9608/41/O/N/16 [Turn over
365
16
Who ..........................................................................................................................................
...................................................................................................................................................
When ........................................................................................................................................
...................................................................................................................................................
Purpose ....................................................................................................................................
...............................................................................................................................................[3]
Who ..........................................................................................................................................
...................................................................................................................................................
When ........................................................................................................................................
...................................................................................................................................................
Purpose ....................................................................................................................................
...............................................................................................................................................[3]
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every reasonable
effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the publisher will
be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.
Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.
Published
This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.
Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.
Cambridge will not enter into discussions about these mark schemes.
Cambridge is publishing the mark schemes for the October/November 2016 series for most
®
Cambridge IGCSE , Cambridge International A and AS Level components and some Cambridge O Level
components.
1 (a) 1 mark for both Set code entered correct. 1 mark for each label. [7]
PYTHON:
def __init__(self):
self.__code = ""
self.__state = "Open-NoCode"
PASCAL/DELPHI:
constructor SafetyDepositBox.Create();
begin
Code := '';
State := 'Open-NoCode';
end;
© UCLES 2016
368
Page 3 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 41
VB:
Public Sub New()
Code = ""
State = "Open-NoCode"
End Sub
PYTHON:
def reset(self):
self.__code = ""
PASCAL/DELPHI:
procedure SafetyDepositBox.Reset();
begin
Code := '';
end;
VB:
Public Sub Reset()
Code = ""
End Sub
PYTHON:
def SetState(self,NewState):
self.__state = NewState
print(self.__state)
PASCAL/DELPHI:
Procedure SetState(NewState : String);
begin
State := NewState
WriteLn(State)
end;
© UCLES 2016
369
Page 4 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 41
VB: VB:
Public Sub SetState(ByVal Private _State As String
NewState As String) Public Property State() As
State = NewState String
Console.WriteLine(State) Get
End Sub Return _State
End Get
Set(value As String)
_State = value
End Set
End Property
Public Sub SetState()
Console.WriteLine(Me.State)
End Sub
PYTHON:
def SetNewCode(self, NewCode):
self.__code = NewCode
print("New code set: ", self.__code)
PASCAL/DELPHI:
procedure SetNewCode(NewCode : String);
begin
Code := NewCode;
WriteLn('New code set: ', Code)
end;
VB:
Public Sub SetNewCode(NewCode)
Code = NewCode
Console.WriteLine("New code set: " & Code)
End Sub
© UCLES 2016
370
Page 5 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 41
PYTHON:
def __valid(self, s):
digits = ['0','1','2','3','4','5','6','7','8','9']
isValid = False
if (len(s) == 4):
if (s[0] in digits) & (s[1] in digits) & (s[2] in digits) &
(s[3] in digits):
isValid = True
return(isValid)
PASCAL/DELPHI:
function Valid(s : string) : Boolean;
var isValid : Boolean; i : integer;
begin
isValid := False
if Length(s) = 4
then
begin
isValid := True;
For i := 1 to 4 do
if (s[i] < '0') OR (s[i] > '9')
then
isValid := False;
end;
end;
© UCLES 2016
371
Page 6 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 41
PYTHON:
def StateChange(self):
Chars = input("Enter code: ")
if Chars == "R":
if self.__state == "Open-CodeSet":
self.reset()
self.SetState("Open-NoCode")
elif Chars == self.__code:
if self.__state == "Locked":
self.SetState("Open-CodeSet")
elif self.__state == "Closed":
self.SetState("Locked")
elif (Chars == "")
& (self.__state == "Open-CodeSet"):
self.SetState("Closed")
elif self.__valid(Chars):
if self.__state == "Open-NoCode":
self.SetNewCode(Chars)
self.SetState("Open-CodeSet")
else:
print("Error - does not match set code")
else:
print("Error - Code format incorrect")
© UCLES 2016
372
Page 7 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 41
PASCAL/DELPHI:
Procedure StateChange();
var Chars : String;
begin
ReadLn(Chars);
If Chars = 'R' Then
If State = 'Open-CodeSet' Then
begin
Reset();
SetState('Open-NoCode');
end
Else
If Chars = Code Then
If state = 'Locked' Then
SetState('Open-CodeSet')
Else
If state = 'Closed' Then
SetState('Locked')
Else
If (Chars = '') AND (State = 'Open-CodeSet') Then
SetState('Closed')
Else
If Valid(Chars) Then
begin
If State == 'Open-NoCode' Then
begin
SetNewCode(Chars);
SetState('Open-CodeSet');
end
else
WriteLn('Error - does not match set code')
end
Else
WriteLn('Error - Code format incorrect');
end;
© UCLES 2016
373
Page 8 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 41
VB:
Public Sub StateChange()
Dim Chars As String
Chars = Console.ReadLine()
If Chars = "R" Then
If State = "Open-CodeSet" Then
Reset()
SetState("Open-NoCode")
End If
ElseIf Chars = Code Then
If state = "Locked" Then
SetState("Open-CodeSet")
ElseIf state = "Closed" Then
SetState("Locked")
End If
ElseIf (Chars = "") AND (State = "Open-CodeSet") Then
SetState("Closed")
ElseIf Valid(Chars) Then
If State == "Open-NoCode" Then
SetNewCode(Chars)
SetState("Open-CodeSet")
Else
Console.WriteLine("Error - does not match set code")
End If
Else
Console.WriteLine("Error - Code format incorrect")
End If
End Sub
PYTHON:
def main():
ThisSafe = SafetyDepositBox()
while True:
ThisSafe.StateChange()
PASCAL/DELPHI:
var ThisSafe : SafetyDepositBox;
ThisSafe := SafetyDepositBox.Create;
while True do
ThisSafe.StateChange;
© UCLES 2016
374
Page 9 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 41
VB:
Sub Main()
Dim ThisSafe As New SafetyDepositBox()
Do
ThisSafe.StateChange()
Loop
End Sub
(ii) Read and mark the answer as one paragraph. Mark a 'how' and a 'when' anywhere in
the answer. [2]
1 mark for when, 1 mark for how.
e.g.
When:
• the error has been typed
• when the program is being run/compiled/interpreted
How:
• highlights/underlines
displays error message/pop-up
(iii)
A B C
© UCLES 2016
375
Page 10 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 41
(ii)
Logic error Logic error Logic error [1]
• breakpoint
• a point where the program can be halted to see if the program works at this point
© UCLES 2016
376
Page 11 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 41
3
START: LDR #0 // initialise index register to zero [1]
LDM #0 // initialise COUNT to zero
[1]
STO COUNT
// load character from indexed address
LOOP1: LDX NAME
NAME [1]
© UCLES 2016
377
Page 12 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 41
4
Acceptance testing Integration testing
Who The end user // user of the The programmer / in-house testers [1] +
software [1]
When When the software is When the separate modules have been [1] +
finished/ when it is installed written and tested [1]
Purpose To ensure the software is To ensure the modules work together as [1] +
what the customer ordered expected [1]
// to check that the software
meets the user requirements
© UCLES 2016
378
at the Centre.
Candidates should use this material in preparation for the examination. Candidates should attempt the
practical programming tasks using their chosen high-level, procedural programming language.
DC (ST) 128071
© UCLES 2016 [Turn over
379
2
Teachers and candidates should read this material prior to the November 2016 examination for
9608 Paper 4.
Reminders
The syllabus states:
• there will be questions on the examination paper which do not relate to this pre-release material
• you must choose a high-level programming language from this list:
• Visual Basic (console mode)
• Python
• Pascal / Delphi (console mode)
Note: A mark of zero will be awarded if a programming language other than those listed is used.
The practical skills for Paper 4 build on the practical skills for Paper 2. We therefore recommend that
candidates choose the same high-level programming language for this paper as they did for Paper 2.
This will give candidates the opportunity for extensive practice and allow them to acquire sufficient
expertise.
Declaration of variables
The syllabus document shows the syntax expected for a declaration statement in pseudocode.
If Python is the chosen language, each variable’s identifier (name) and its intended data type must be
documented using a comment statement.
TASK 1
When writing high-level language programs you are asked to use one of:
• Python
• Visual Basic (console mode)
• Pascal/Delphi (console mode) Key focus: Programming environments
Make sure you know the name of the programming environment that you use to write programs in your
chosen programming language.
TASK 1.1
Explore the features of your editor that help you to write program code.
When and how does your programming environment report syntax errors?
TASK 1.2
When you write program code, explore debugger features available to you and practise using them to
step through programs and explore the state of the variables after each instruction.
Explore how the debugger can help to find logic errors and run-time errors.
TASK 1.3
You will need to write a main program that initialises and populates an array of names to be sorted.
The program then calls the procedure Sort.
Decide on some test data. Write down the expected results after each repetition (iteration) of the FOR
loop. You should test your program with several different sets of data. Use the debugger each time to
step through the program.
Extension task
Explore what program libraries are available for your chosen programming language. How can you
make use of a library routine that is not part of the basic set-up of your programming environment?
TASK 2
The table shows part of the instruction set for a processor which has one general purpose register, the
Accumulator (ACC), and an index register (IX).
Note: These instructions are all referred to in syllabus sections 1.4.3 and 3.6.2.
Instruction
Op Explanation
Operand
code
LDM #n Immediate addressing. Load the number n to ACC
LDD <address> Direct addressing. Load the contents of the given address to ACC
Indirect addressing. The address to be used is at the given address. Load the
LDI <address>
contents of this second address to ACC
Indexed addressing. Form the address from <address> + the contents of the
LDX <address>
index register. Copy the contents of this calculated address to ACC
LDR #n Immediate addressing. Load the number n into IX
STO <address> Store the contents of ACC at the given address
ADD <address> Add the contents of the given address to the ACC
INC <register> Add 1 to the contents of the register (ACC or IX)
DEC <register> Subtract 1 from the contents of the register (ACC or IX)
JMP <address> Jump to the given address
CMP <address> Compare the contents of ACC with the contents of <address>
CMP #n Compare the contents of ACC with number n
JPE <address> Following a compare instruction, jump to <address> if the compare was TRUE
JPN <address> Following a compare instruction, jump to <address> if the compare was FALSE
AND #n Bitwise AND operation of the contents of ACC with the operand
AND <address> Bitwise AND operation of the contents of ACC with the contents of <address>
XOR #n Bitwise XOR operation of the contents of ACC with the operand
XOR <address> Bitwise XOR operation of the contents of ACC with the contents of <address>
OR #n Bitwise OR operation of the contents of ACC with the operand
OR <address> Bitwise OR operation of the contents of ACC with the contents of <address>
IN Key in a character and store its ASCII value in ACC
OUT Output to the screen the character whose ASCII value is stored in ACC
END Return control to the operating system
Notes:
Tasks 2.1 to 2.7 all use one of the following two formats for symbolic addressing.
Format Example
<label>: <op code> <operand> START: LDA #0
<label>: <data> NUM1: B01001010
Write assembly language program code using the instruction set provided on page 4.
TASK 2.1
X ← A + B
END
Instruction
Label Op Comment
Operand
code
START: // load the content of A into ACC
X:
A: 5
B: 3
TASK 2.2
IF X = A
THEN
OUTPUT CHR(X) // statements for THEN part
ELSE
A ←
A + 1 // statements for ELSE part
ENDIF
END
Instruction
Label Op Comment
Operand
code
START: // load the content of X into ACC
A: 65
X: 67
Note: the built-in function CHR(X) returns the character that is represented by the ASCII code held in X.
TASK 2.3
REPEAT
OUTPUT CHR(X)
X ← X - 1
UNTIL X = A
END
Instruction
Label Op Comment
Operand
code
LOOP: // instructions to be repeated start here
X: 90
A: 65
TASK 2.4
FOR COUNT ←
1 TO 4
OUTPUT CHARS[COUNT]
ENDFOR
END
Instruction
Label Op Comment
Operand
code
// set ACC to zero
// COUNT = 4 ?
COUNT:
CHARS: 72 // 'H'
69 // 'E'
76 // 'L'
80 // 'P'
TASK 2.5
WHILE X <> B
OUTPUT CHARS[B]
B ← B + 1
ENDWHILE
END
Instruction
Label Op Comment
Operand
code
LOOP: // load content of X into ACC
// is content of ACC = content of B ?
// if equal (TRUE) jump to ENDWHILE
// instructions to be repeated start here
X: 4
B: 0
CHARS: 72 // 'H'
69 // 'E'
76 // 'L'
80 // 'P'
TASK 2.6
Instruction
Address Op Comment
Operand
code
// use indirect addressing to load contents of
LOOP:
address found at address 100
// output character with ASCII code held in ACC
// increment ACC
100 102
101
102 77 // 'M'
103 65 // 'A'
104 84 // 'T'
105 72 // 'H'
106 83 // 'S'
107
TASK 2.7
Programmers use bitwise operations (AND, OR, XOR) to set or examine specific bits.
Example:
Instruction
Label Op Comment
Operand
code
LOOP: LDD X // load content of X into ACC
// bitwise AND operation on content of ACC and
AND MASK
content of MASK
STO Y // store content of ACC in Y
X: B10101111
MASK: B00000001
Write simple programs using the different bitwise operations (AND, OR, XOR) and different MASK content.
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every reasonable
effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the publisher will
be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.
Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
DC (LEG/SW) 115870/4
© UCLES 2016 [Turn over
391
2
1 The ticket machine in the following diagram accepts the following coins: 10, 20, 50 and 100 cents.
• button A (Accept)
• button C (Cancel)
$
Coin Slot
&
Coin
return Ticket dispenser
tray
When the user has inserted as many coins as required, they press button A to print the ticket.
To cancel the transaction, the user can press button C. This makes the machine return the coins.
The following state transition table shows the transition from one state to another of the ticket
machine:
start
Coin inserted
.......................................................
............................ ............................
Cancelled
Coins returned
.......................................................
.......................................................
.......................................................
............................
[7]
(b) A company wants to simulate the use of a ticket machine. It will do this with object-oriented
programming (OOP).
The following diagram shows the design for the class TicketMachine. This includes its
attributes and methods.
TicketMachine
Amount : INTEGER // total value of coins inserted in cents
State : STRING // "Idle", "Counting", "Cancelled"
// or "Accepted"
Create() // method to create and initialise an object
// if using Python use __init__
SetState() // set state to parameter value
// and output new state
StateChange() // insert coin or press button,
// then take appropriate action
CoinInserted() // parameter is a string
// change parameter to integer
// and add coin value to Amount
ReturnCoins() // output Amount, then set Amount to zero
PrintTicket() // print ticket, then set Amount to zero
(i) Create()
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
(ii) SetState()
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
(iii) ReturnCoins()
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
(iv) Each coin inserted must be one of the following: 10, 20, 50 or 100 cents.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
(vi) Convert the flowchart to program code for the method StateChange().
Use the attributes and methods in the original class definition and the ValidCoin()
function from part (iv).
METHOD StateChange
INPUT NewInput
No
CALL ReturnCoins()
No
No No
Is NewInput Yes
CALL CoinInserted(NewInput)
a valid
coin?
No
CALL SetState("Counting") CALL SetState("Idle")
OUTPUT "Error –
not a valid
coin"
ENDMETHOD
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.....................................................................................................................................[12]
© UCLES 2016 9608/42/O/N/16 [Turn over
397
8
(vii) The company needs to write a program to simulate a parking meter. The program
will create an object with identifier ParkingMeter, which is an instance of the class
TicketMachine.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[4]
TicketMachine
PRIVATE
Amount : INTEGER
State : STRING
PUBLIC
Create()
StateChange()
PRIVATE
SetState()
CoinInserted()
ReturnCoins()
PrintTicket()
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
(ii) Describe the effects of declaring two methods of the class as public and the other four as
private.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
Who ...................................................................................................................................
...........................................................................................................................................
When .................................................................................................................................
...........................................................................................................................................
Purpose .............................................................................................................................
.......................................................................................................................................[3]
Who ...................................................................................................................................
...........................................................................................................................................
When .................................................................................................................................
...........................................................................................................................................
Purpose .............................................................................................................................
.......................................................................................................................................[3]
3 (a) The numerical difference between the ASCII code of an upper case letter and the ASCII code
of its lower case equivalent is 32 denary (3210).
For example, 'F' has ASCII code 70 and 'f' has ASCII code 102.
Bit number
7 6 5 4 3 2 1 0
ASCII code ASCII code in binary
70 0 1 0 0 0 1 1 0
102 0 1 1 0 0 1 1 0
The bit patterns differ only at bit number 5. This bit is 1 if the letter is lower case and 0 if the
letter is upper case.
Write the binary pattern of the mask in the space provided in the table below.
Bit number
7 6 5 4 3 2 1 0
ASCII code ASCII code in binary
70 0 1 0 0 0 1 1 0
102 0 1 1 0 0 1 1 0
Mask
Give the bit-wise operation that needs to be performed using the mask and the
ASCII code.
.......................................................................................................................................[2]
Write the binary pattern of the mask in the space provided in the table below.
Bit number
7 6 5 4 3 2 1 0
ASCII code ASCII code in binary
70 0 1 0 0 0 1 1 0
102 0 1 1 0 0 1 1 0
Mask
Give the bit-wise operation that needs to be performed using the mask and the
ASCII code.
.......................................................................................................................................[2]
The following table shows part of the instruction set for a processor which has one general
purpose register, the Accumulator (ACC), and an index register (IX).
Instruction
Op Operand Explanation
code
LDM #n Immediate addressing. Load the number n to ACC.
Direct addressing. Load the contents of the given address to
LDD <address>
ACC.
Indexed addressing. Form the address from <address> +
LDX <address> the contents of the index register. Copy the contents of this
calculated address to ACC.
LDR #n Immediate addressing. Load the number n into IX.
STO <address> Store the contents of ACC at the given address.
INC <register> Add 1 to the contents of the register (ACC or IX).
CMP <address> Compare the contents of ACC with the contents of <address>.
CMP #n Compare the contents of ACC with number n.
Following a compare instruction, jump to <address> if the
JPE <address>
compare was True.
Following a compare instruction, jump to <address> if the
JPN <address>
compare was False.
Bitwise AND operation of the contents of ACC with the
AND #n
operand.
Bitwise AND operation of the contents of ACC with the
AND <address>
contents of <address>.
Bitwise XOR operation of the contents of ACC with the
XOR #n
operand.
Bitwise XOR operation of the contents of ACC with the
XOR <address>
contents of <address>.
OR #n Bitwise OR operation of the contents of ACC with the operand.
Bitwise OR operation of the contents of ACC with the contents
OR <address>
of <address>.
Output to the screen the character whose ASCII value is
OUT
stored in ACC.
END Return control to the operating system.
A programmer is writing a program that will output the first character of a string in upper case and
the remaining characters of the string in lower case.
The program will use locations from address WORD onwards to store the characters in the string.
The location with address LENGTH stores the number of characters that make up the string.
The programmer has started to write the program in the following table. The comment column
contains descriptions for the missing program instructions.
(b) Complete the program using op codes from the given instruction set.
Op
Label Operand Comment
code
START: // initialise index register to zero
// get first character of WORD
// ensure it is in upper case using MASK1
// output character to screen
// increment index register
// load 1 into ACC
// store in COUNT
LOOP: // load next character from indexed address WORD
// make lower case using MASK2
// output character to screen
// increment COUNT starts here
// is COUNT = LENGTH ?
// if FALSE, jump to LOOP
// end of program
COUNT:
MASK1: // bit pattern for upper case
MASK2: // bit pattern for lower case
LENGTH: 4
WORD: B01100110 // ASCII code in binary for 'f'
B01110010 // ASCII code in binary for 'r'
B01000101 // ASCII code in binary for 'E'
B01000100 // ASCII code in binary for 'D'
[12]
(a) (i) Name the programming environment you have used when typing in program code.
...........................................................................................................................................
...........................................................................................................................................
List three features of the editor that helped you to write program code.
1 .........................................................................................................................................
...........................................................................................................................................
2 .........................................................................................................................................
...........................................................................................................................................
3 .........................................................................................................................................
.......................................................................................................................................[3]
(ii) Explain when and how your programming environment reports a syntax error.
When .................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
How ...................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
(iii) The table shows a module definition for BubbleSort in three programming languages.
A B C
A) Python
01 def BubbleSort(SList, Max):
02 NoMoreSwaps = False
03 while NoMoreSwaps == False:
04 NoMoreSwaps = True
05 for i in (Max - 1):
06 if SList[i] > SList[i + 1]:
07 NoMoreSwaps = True
08 Temp = SList[i]
09 SList[i] = SList[i + 1]
10 SList[i + 1] = Temp
B) Pascal/Delphi
01 PROCEDURE BubbleSort(VAR SList : ARRAY OF INTEGER; Max : INTEGER);
02 VAR NoMoreSwaps : BOOLEAN; i, Temp : INTEGER;
03 BEGIN
04 REPEAT
05 NoMoreSwaps := TRUE;
06 FOR i := 1 TO (Max – 1)
07 IF SList[i] > SList[i + 1]
08 THEN
09 BEGIN
10 NoMoreSwaps := TRUE;
11 Temp := SList[i];
12 SList[i] := SList[i + 1];
13 SList[i + 1] := Temp;
14 END;
15 UNTIL NoMoreSwaps;
16 END;
C) Visual Basic
01 Sub BubbleSort(ByRef SList() As Integer, ByVal Max As Integer)
02 Dim NoMoreSwaps As Boolean, i, Temp As Integer
03 Do
04 NoMoreSwaps = True
05 For i : 0 To (Max – 1)
06 If SList(i) > SList(i + 1) Then
07 NoMoreSwaps = True
08 Temp = SList(i)
09 SList(i) = SList(i + 1)
10 SList(i + 1) = Temp
11 End If
12 Next
13 Loop Until (NoMoreSwaps = True)
14 End Sub
...............................................................................................................................................[2]
(b) (i) State whether programs written in your programming language are compiled or
interpreted.
...........................................................................................................................................
.......................................................................................................................................[1]
(ii) A programmer corrects the syntax error and tests the function. It does not perform as
expected. The items are not fully in order.
...........................................................................................................................................
.......................................................................................................................................[2]
(iii) State the programming environment you have used when debugging program code.
...........................................................................................................................................
Name two debugging features and describe how they are used.
1 ........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
2 ........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[4]
Published
This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.
Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.
Cambridge will not enter into discussions about these mark schemes.
Cambridge is publishing the mark schemes for the October/November 2016 series for most
®
Cambridge IGCSE , Cambridge International A and AS Level components and some Cambridge O Level
components.
1 (a) [7]
© UCLES 2016
409
Page 3 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 42
e.g.
PYTHON:
def __init__(self):
self.__amount = 0
self.__state = "Idle"
PASCAL/DELPHI:
constructor TicketMachine.Create();
begin
Amount := 0;
State := 'Idle';
end;
VB: VB:
Public Sub New() Public Sub Create()
Amount = 0 Amount = 0
State = "Idle" state = “Idle”
End Sub End Sub
e.g.
PYTHON:
def SetState(self, NewState):
self.__State = NewState
print(self.__State)
PASCAL/DELPHI:
procedure TicketMachine.SetState(NewState : string);
begin
State := NewState;
Writeln(State);
end;
© UCLES 2016
410
Page 4 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 42
VB: VB:
Public Sub SetState(NewState As Private _State As String
String) Public Property State() As
Me.State = NewState String
Console.WriteLine(Me.State) Get
End Sub Return _State
End Get
Set(value As String)
_State = value
End Set
End Property
Public Sub SetState()
Console.WriteLine(Me.State)
End Sub
e.g.
PYTHON:
def ReturnCoins(self):
print(self.__Amount)
self.__Amount = 0
PASCAL/DELPHI:
procedure TicketMachine.ReturnCoins();
begin
Writeln(Amount);
Amount := 0;
end;
VB:
Public Sub ReturnCoins()
Console.WriteLine(Me.Amount)
Me.Amount = 0
End Sub
© UCLES 2016
411
Page 5 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 42
e.g.
PYTHON:
def __validCoin(self, s):
coins = ['10','20','50','100']
if s in coins:
isValid = True
else:
isValid = False
return(isValid)
PASCAL/DELPHI:
function TicketMachine.ValidCoin(s : string) : boolean;
begin
if ((s = '10') or (s = '20') or (s = '50') or (s = '100'))
then
ValidCoin:= True;
else
ValidCoin := False;
end;
VB:
Public Function ValidCoin(ByVal s As String) As Boolean
If s = “10” or s = “20” or s = “50” or s = “100” Then
ValidCoin = True
Else
ValidCoin = False
End If
End Sub
© UCLES 2016
412
Page 6 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 42
e.g.
PYTHON:
def coinInserted(self, s):
coinValue = int(s)
self.__amount = self.__amount + coinValue
PASCAL/DELPHI:
procedure TicketMachine.CoinInserted(s : string);
var
CoinValue, Code : integer;
begin
Val(s, CoinValue, Code);
Amount := Amount + CoinValue;
end;
VB:
Public Sub CoinInserted(ByVal S As String)
CoinValue = INT(s)
Me.Amount = Me.Amount + CoinValue
End Sub
© UCLES 2016
413
Page 7 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 42
e.g.
PYTHON:
def stateChange(self):
newInput = input("Insert coin: ")
if newInput == "C":
if self.__state == "Counting":
self.setState("Cancelled")
self.returnCoins()
self.setState("Idle")
elif newInput == "A":
if self.__amount == 0:
print("no coins inserted")
else:
self.setState("Accepted")
self.__PrintTicket()
self.setState("Idle")
elif self.__validCoin(newInput):
self.coinInserted(newInput)
self.setState("Counting")
else:
print("Error - not a valid coin")
PASCAL/DELPHI:
procedure TicketMachine.StateChange();
var
NewInput : string;
begin
Write('Insert coin: ');
Readln(NewInput);
if (NewInput = 'C') then
begin
if (State = 'Counting') then
begin
State := 'Cancelled';
ReturnCoins();
end;
SetState('Idle')
end
else
if (NewInput = 'A') then
© UCLES 2016
414
Page 8 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 42
begin
if (Amount = 0) then
Writeln('No coins inserted')
else
begin
SetState('Accepted');
PrintTicket();
end;
SetState('Idle');
end
else
if (ValidCoin(NewInput)) then
begin
CoinInserted(NewInput);
SetState('Counting')
end
else
Writeln('Error - not a valid coin')
end;
VB:
Public Sub StateChange()
Dim NewInput As String
NewInput = Console.Readline()
If NewInput = “C” Then
If State = “Counting” Then
SetState(“Cancelled”)
ReturnCoins()
End If
SetState(“Idle”)
Elseif NewInput = “A” Then
If Amount = 0 Then
Console.Writeline(“No coins inserted”)
Else
SetState(“Accepted”)
PrintTicket()
Endif
SetState(“Idle”)
Elseif ValidCoin(NewInput) Then
CoinInserted(NewInput)
SetState(“Counting”)
Else
Console.Writeline(“Error – not a valid coin”)
EndIf
End Sub
© UCLES 2016
415
Page 9 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 42
e.g.
PYTHON:
def main():
ParkingMeter = TicketMachine()
while True:
ParkingMeter.stateChange()
PASCAL/DELPHI:
begin
ParkingMeter := TicketMachine.Create();
while True do
ParkingMeter.StateChange();
end.
VB:
Sub Main()
Dim ParkingMeter As New TicketMachine
ParkingMeter.Create()
While (True)
Call ParkingMeter.StateChange()
End While
End Sub
© UCLES 2016
416
Page 10 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 42
• The public methods can be called anywhere in the main program // Public methods
can be inherited by sub-classes
• The private methods can only be called within the class definition // cannot be called
outside the class definition // Private methods cannot be inherited by sub-classes
2 [6]
(i) Alpha testing (ii) Beta testing
© UCLES 2016
417
Page 11 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 42
INC ACC // 1
STO COUNT //
COUNT: 0
LENGTH: 4
[max 12]
© UCLES 2016
418
Page 12 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 42
e.g.
• auto-indent
• auto-complete / by example
• colour-coded keywords/ strings/ comments/ built-in functions/ user-defined function
names pop-up help
• can set indent width
• expand/collapse subroutines/code
• block highlighting
(ii) Read and mark the answer as one paragraph. Mark a how and a when anywhere in the
answer.
1 mark for when, 1 mark for how.
e.g.
When:
• the error has been typed
• when the program is being run/compiled/interpreted
How:
• highlights/underlines
displays error message/pop-up
(iii) 1 mark for identifying the correct line, 1 mark for writing the corrected line
© UCLES 2016
419
Page 13 Mark Scheme Syllabus Paper
Cambridge International A Level – October/November 2016 9608 42
(ii) 1 mark for naming error, 1 mark for line number and correction
7 10 7 [1]
NoMoreSwaps = False NoMoreSwaps := NoMoreSwaps =
FALSE; False
• breakpoint
• a point where the program can be halted to see if the program works at this point
© UCLES 2016
420
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
DC (ST/SW) 158024/4
© UCLES 2017 [Turn over
421
2
TYPE MyContactDetail
DECLARE Name : STRING
DECLARE HouseNumber : INTEGER
ENDTYPE
.......................................................................................................................................[1]
(ii) Write a pseudocode statement that assigns 129 to the HouseNumber of NewFriend.
.......................................................................................................................................[1]
• adding a field called Area which can take three values, uptown, downtown or midtown
• amending the field HouseNumber so that house numbers can only be in the range 1 to
499.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[3]
(c) A pointer is a variable that stores the address of a variable of a particular type.
The four assignment statements are executed. The diagram shows the memory contents
after execution.
Memory
Variable Contents
Address
...
5848
5847
IPointer 5846 4402
5845
...
4403
Sum 4402 33
4401
...
3428
MyInt1 3427 91
MyInt2 3426 33
3425
...
Use the diagram to state the current values of the following expressions:
.......................................................................................................................................[1]
.......................................................................................................................................[1]
(iii) Copy the value in MyInt2 into the memory location currently pointed at by IPointer.
.......................................................................................................................................[1]
2 The following incomplete table shows descriptions and terms relating to malware.
Description Term
(i) Malicious code is installed on a personal computer
so that the user is misdirected to a fraudulent web ...................................... [1]
site without their knowledge.
(ii) An attempt to acquire sensitive information, often
for malicious reasons, by trying to deceive the user ...................................... [1]
through the contents of an email.
(iii)
.................................................................................
.................................................................................
.................................................................................
Worm
.................................................................................
.................................................................................
................................................................................. [2]
(b) State two vulnerabilities that the malware in part (a)(i) or part (a)(ii) can exploit.
Vulnerability 1 ...........................................................................................................................
...................................................................................................................................................
Vulnerability 2 ...........................................................................................................................
...................................................................................................................................................
[2]
(c) Digital certificates are used in internet communications. A Certificate Authority (CA) is
responsible for issuing a digital certificate.
1 ........................................................................................................................................
2 ........................................................................................................................................
3 ........................................................................................................................................
[3]
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
(iii) Give the reason for including a digital signature in the digital certificate.
...........................................................................................................................................
.......................................................................................................................................[1]
S
Q
(a) Write the Boolean algebraic expression corresponding to this logic circuit:
S = ........................................................................................................................................[4]
P Q R Working space S
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
[2]
(c) (i) Complete the Karnaugh Map (K-map) for the truth table in part (b).
PQ
00 01 11 10
0
R
1
[1]
(ii) Draw loop(s) around appropriate groups to produce an optimal sum-of-products. [1]
(iii) Write a simplified sum-of-products expression, using your answer to part (ii).
S = .................................................................................................................................[1]
Simplify the expression for S in part (a) to the expression for S in part (c)(iii).
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[3]
© UCLES 2017 9608/32/M/J/17 [Turn over
427
8
4 (a) Three file organisation methods and two file access methods are shown below.
Draw lines to link each file organisation method to its appropriate file access method(s).
random sequential
serial direct
sequential
[4]
(b) An energy company supplies electricity to a large number of customers. Each customer has
a meter that records the amount of electricity used. Customers submit meter readings using
their online account.
• account number
• personal data (name, address, telephone number)
• meter readings
• username and encrypted password.
For each of the files A, B and C, state an appropriate file organisation method for the use
given in the table.
Justification .......................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
Justification .......................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
Justification .......................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
5 The TCP/IP protocol suite can be viewed as a stack with four layers.
(a) Complete the stack by inserting the names of the three missing layers.
Application layer
[3]
(b) BitTorrent is a protocol used at the Application layer for the exchange of data.
.......................................................................................................................................[1]
.......................................................................................................................................[1]
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[4]
(c) State two additional protocols that are also used at the Application layer for the exchange of
data.
Protocol 1 .................................................................................................................................
Example ....................................................................................................................................
...................................................................................................................................................
Protocol 2 .................................................................................................................................
Example ....................................................................................................................................
...................................................................................................................................................
[4]
6 A large office building has many floors. On each floor there are security sensors and security
cameras. There is the same number of sensors on each floor. The building has a single security
room.
The images from the security cameras are output on monitors (one monitor for each floor) placed
in the security room.
The data from the sensors are read and processed by a computer system. Sensor readings and
warning messages can be displayed on the monitors.
(a) (i) State the name given to the type of system described.
.......................................................................................................................................[1]
...........................................................................................................................................
.......................................................................................................................................[1]
Sensor 1 ............................................................................................................................
Sensor 2 ............................................................................................................................
[2]
01 ForEver ...............................................................................................................
02 REPEAT
03 FOR FloorCounter 1 TO NumberOfFloors
04 FOR SensorCounter 1 TO ......................................................................
05 READ Sensor(SensorCounter)on Floor(FloorCounter)
06 IF Sensor value outside range
07 THEN
08 OUTPUT “Problem on Floor ”, FloorCounter
09 ENDIF
10 ENDFOR
11 ENDFOR
12 //
13 // Delay loop
14 // Delay loop
15 //
16 UNTIL .........................................................................................................................
[3]
...........................................................................................................................................
.......................................................................................................................................[1]
...........................................................................................................................................
.......................................................................................................................................[1]
(c) An alternative method of reading and processing sensor data is to use interrupts. Each sensor
is connected so that it can send an interrupt signal to the processor if its value changes.
On receipt of an interrupt signal, the processor carries out a number of steps as shown in the
following diagram.
3. Identify source of
interrupt
4. Jump to Interrupt
Service Routine
5. Restore task
...........................................................................................................................................
.......................................................................................................................................[1]
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
BLANK PAGE
BLANK PAGE
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.
Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.
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.
For example:
TYPE MyContactDetail
DECLARE Name : STRING
DECLARE Area : (uptown, downtown, midtown) 1
DECLARE HouseNumber : 1..499 1&1
ENDTYPE
1(c)(i) 4402 1
1(c)(ii) 33 1
1(c)(iii) 3427 1
1(c)(iv) TRUE 1
1(d)(ii) MyInt1 ← 33 1
2(a)(i) Pharming 1
2(a)(ii) Phishing 1
2(b) No up-to-date anti-virus (or equivalent) software (used) / Regular virus scans not 2
performed
No firewall
Operating system not up-to-date/obsolete
Attachments/suspicious links in emails clicked on
Clicking on website with an out of date security certificate
max 2
2(c)(iii) Need to know that the certificate is genuine (and has not been altered) 1
// Authenticate or verify it (came from the CA)
3(a) S = ( P + (Q+R) ) . R 4
P 1
(Q +R) 1
( P +( Q + R ) ) 1
.R (must be outside final brackets) 1
Or
P 1
(Q +R) 1
P +( Q + R ) 1
(«««..). R 1
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 0
1 1 0 0
1 1 1 0
2 marks all correct, 1 mark seven correct, 0 marks six or fewer correct
3(c)(i) PQ 1
00 01 11 10
0 0 0 0 0
R
1 1 1 0 0
3(c)(ii) PQ 1
00 01 11 10
0 0 0 0 0
R
1 1 1 0 0
3(c)(iii) S= P .R 1
3(d) S = (P + ( Q + R ) ) . R 3
S = ( P + ( Q . R ) ) . R // P .R + ( Q + R ) . R 1
S = (P . R ) + ( Q . R . R ) 1
S= P . R + Q . 0 )
S= P . R + 0 ) 1
S= P . R
random sequential
serial direct
sequential
4(b)(i) File A: 3
Serial 1
Meter readings are submitted over time // added to the end of file 1
Stored chronologically 1
4(b)(ii) File B: 3
Sequential 1
Any two points from:
Each customer has a unique account number 1
Sorted on Account number 1
High hit rate // Suitable for batch processing monthly statements 1
4(b)(iii) File C: 3
Random 1
Login without waiting // Random organisation allows fastest direct access to
required record 1
Low hit rate // Suitable for access to individual records 1
5(b)(i) Peer-to-peer 1
6(a)(ii) There is no element of ‘control’ in the system // the system does not alter 1
conditions in the building if sensors triggered
Candidates should use this material in preparation for the examination. Candidates should attempt the
practical programming tasks using their chosen high-level, procedural programming language.
DC (ST/SW) 144372/1
© UCLES 2017 [Turn over
444
2
Teachers and candidates should read this material prior to the June 2017 examination for 9608 Paper 4.
Reminders
• there will be questions on the examination paper which do not relate to this pre-release material
• you must choose a high-level programming language from this list:
Note: A mark of zero will be awarded if a programming language other than those listed is used.
The practical skills for Paper 4 build on the practical skills covered in Paper 2. We therefore recommend
that candidates choose the same high-level programming language for this paper as they did for
Paper 2. This will give candidates the opportunity for extensive practice and allow them to acquire
sufficient expertise.
• structured English
• pseudocode
• program code
Candidates will also benefit from using pre-release materials from previous examinations. These are
available on the teacher support site.
Declaration of variables
The syllabus document shows the syntax expected for a declaration statement in pseudocode.
If Python is the chosen language, each variable’s identifier (name) and its intended data type must be
documented using a comment statement.
TASK 1
Students at a college are given several tests during their course. A teacher wants to write
object-oriented software to process data about the tests.
For each test, the following are to be stored:
TASK 1.1
The relationship between Test and Question is shown in the following containment (aggregation)
class diagram.
Test Question
– TestID : String – QuestionID : String
– Questions [1 : 10] : Question – QuestionText : String
– NumberOfQuestions : Integer – Answer : String
1 1..*
– MaxMarks : Integer – Marks : Integer
– Level : Char – Topic : String
– DateSet : Date
+ SetQuestion()
+ DesignTest() + GetQuestion() : String
+ PrintTest() + GetMarks() : Integer
+ PrintAnswers() + GetTopic() : String
+ GetAnswer() : String
TASK 1.2
TASK 2
The table shows part of the instruction set for a processor which has one general purpose register, the
Accumulator (ACC), and an Index Register (IX).
Note: these instructions are referred to in the syllabus sections 1.4.3 and 3.6.2.
Instruction
Op Explanation
Operand
code
LDM #n Immediate addressing. Load the number n to ACC.
Direct addressing. Load the contents of the location at the given address to
LDD <address>
ACC.
Indirect addressing. The address to be used is at the given address. Load the
LDI <address>
contents of this second address to ACC.
Indexed addressing. Form the address from <address> + the contents of the
LDX <address>
index register. Copy the contents of this calculated address to ACC.
LDR #n Immediate addressing. Load the number n into IX.
STO <address> Store the contents of ACC at the given address.
ADD <address> Add the contents of the given address to the ACC.
INC <register> Add 1 to the contents of the register (ACC or IX).
DEC <register> Subtract 1 from the contents of the register (ACC or IX).
JMP <address> Jump to the given address.
CMP <address> Compare the contents of ACC with the contents of <address>.
CMP #n Compare the contents of ACC with number n.
JPE <address> Following a compare instruction, jump to <address> if the compare was TRUE.
JPN <address> Following a compare instruction, jump to <address> if the compare was FALSE.
AND #n Bitwise AND operation of the contents of ACC with the operand.
AND <address> Bitwise AND operation of the contents of ACC with the contents of <address>.
XOR #n Bitwise XOR operation of the contents of ACC with the operand.
XOR <address> Bitwise XOR operation of the contents of ACC with the contents of <address>.
OR #n Bitwise OR operation of the contents of ACC with the operand.
OR <address> Bitwise OR operation of the contents of ACC with the contents of <address>.
IN Key in a character and store its ASCII value in ACC.
OUT Output to the screen the character whose ASCII value is stored in ACC.
END Return control to the operating system.
Notes:
Tasks 2.1 to 2.7 all use one of the following two formats for symbolic addressing.
Format Example
<label>: <op code> <operand> START: LDM #0
<label>: <data> NUM1: B01001010
Tasks 2.1 to 2.5 show high-level language constructs written in pseudocode. Each task consists of
writing the assembly language equivalent of the given high-level language construct.
Write assembly language program code using the given instruction set.
TASK 2.1
X A + B
END
Instruction
Label Op Comment
Operand
code
X:
A: 5
B: 3
TASK 2.2
IF X = A
THEN
OUTPUT CHR(X) // statements for THEN part
ELSE
A A + 1 // statements for ELSE part
ENDIF
END
Instruction
Label Op Comment
Operand
code
A: 65
X: 67
Note: the built-in function CHR(X) returns the character that is represented by the ASCII code held
in X.
TASK 2.3
REPEAT
OUTPUT CHR(X)
X X - 1
UNTIL X = A
END
Instruction
Label Op Comment
Operand
code
X: 90
A: 65
TASK 2.4
FOR COUNT 1 TO 4
OUTPUT CHARS[COUNT]
ENDFOR
END
Instruction
Label Op Comment
Operand
code
// set ACC to 1
// set IX to 0
// increment IX
// jump to LOOP
COUNT:
CHARS: 72 // 'H'
69 // 'E'
76 // 'L'
80 // 'P'
TASK 2.5
WHILE X <> B
OUTPUT CHARS[B]
B B + 1
ENDWHILE
END
Instruction
Label Op Comment
Operand
code
LOOP: // load contents of X into ACC
// is contents of ACC = contents of B ?
// if equal (TRUE), jump to ENDWHILE
// instructions to be repeated start here
// set IX to B starts here
// set ACC to 1
// store content of ACC in FORCOUNT
// FORCOUNT = B + 1 ? starts here
// decrement ACC to FORCOUNT - 1
// FORCOUNT – 1 = B ?
// if equal (TRUE), jump to ENDFOR
// increment IX
TASK 2.6
Instruction
Address Op Comment
Operand
code
// use indirect addressing to load contents of
LOOP:
address found at address 100
// increment ACC
100 102
101
102 77 // 'M'
103 65 // 'A'
104 84 // 'T'
105 72 // 'H'
106 83 // 'S'
107
TASK 2.7
Programmers use bitwise operations (AND, OR, XOR) to set or examine specific bits.
Example:
Instruction
Label Op Comment
Operand
code
X: B10101111
MASK: B00000001
Write simple programs using the different bitwise operations (AND, OR, XOR) and different MASK content.
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.
Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
DC (CW/SW) 129963/3
© UCLES 2017 [Turn over
456
2
1 The following table shows part of the instruction set for a processor which has one general purpose
register, the Accumulator (ACC), and an Index Register (IX).
Instruction
Explanation
Op code Operand
LDM #n Immediate addressing. Load the number n to ACC.
LDD <address> Direct addressing. Load the contents of the location at the given address
to ACC.
LDI <address> Indirect addressing. The address to be used is at the given address.
Load the contents of this second address to ACC.
LDX <address> Indexed addressing. Form the address from <address> + the contents of
the index register. Copy the contents of this calculated address to ACC.
STO <address> Store the contents of ACC at the given address.
INC <register> Add 1 to the contents of the register (ACC or IX).
CMP <address> Compare the contents of ACC with the contents of <address>.
JMP <address> Jump to the given address.
JPE <address> Following a compare instruction, jump to <address> if the compare was
True.
JPN <address> Following a compare instruction, jump to <address> if the compare was
False.
AND <address> Bitwise AND operation of the contents of ACC with the contents of
<address>.
XOR <address> Bitwise XOR operation of the contents of ACC with the contents of
<address>.
OR <address> Bitwise OR operation of the contents of ACC with the contents of
<address>.
IN Key in a character and store its ASCII value in ACC.
OUT Output to the screen the character whose ASCII value is stored in ACC.
END Return control to the operating system.
• reads two characters input from the keyboard (you may assume they will be capital
letters in ascending alphabetical sequence)
• outputs the alphabetical sequence of characters from the first to the second character.
For example, if the characters ‘B’ and ‘F’ are input, the output is:
BCDEF
The programmer has started to write the program in the following table. The Comment column
contains descriptions for the missing program instructions, labels and data.
Complete the following program. Use op codes from the given instruction set.
Op
Label Operand Comment
code
START: // INPUT character
// store in CHAR1
// INPUT character
// store in CHAR2
// initialise ACC to ASCII value of CHAR1
// output contents of ACC
// compare ACC with CHAR2
// if equal jump to end of FOR loop
// increment ACC
// jump to LOOP
ENDFOR: END
CHAR1:
CHAR2:
[9]
• converts a positive integer, stored at address NUMBER1, into its negative equivalent in
two’s complement form
• stores the result at address NUMBER2
Complete the following program. Use op codes from the given instruction set.
Show the value stored in NUMBER2.
Op
Label Operand Comment
code
START:
MASK // convert to one's complement
// convert to two's complement
END
MASK: // show value of mask in binary here
NUMBER1: B00000101 // positive integer
NUMBER2: // negative equivalent
[6]
2 An ordered binary tree Abstract Data Type (ADT) has these associated operations:
• create tree
• add new item to tree
• traverse tree
...................................................................................................................................................
...............................................................................................................................................[1]
(b) The following diagram shows an ordered binary tree after the following data have been
added:
RootPointer
Dublin
Ø Berlin Ø London
Ø Copenhagen Ø Paris Ø
Ø Madrid Ø
Make the required changes to the diagram when this data item is added. [2]
(c) A tree without any nodes Unused nodes are linked together into a free list
is represented as: as shown:
RootPointer FreePointer
Ø
Ø Ø
The following diagram shows an array of records that stores the tree shown in part (b).
[1] London
[2] Berlin
[3] Paris
[4] Madrid
[6] Athens
[7]
[8]
[9]
[5]
(ii) Give an appropriate numerical value to represent the null pointer for this design. Justify
your answer.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
(d) A program is to be written to implement the tree ADT. The variables and procedures to be
used are listed below:
TYPE Node
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
ENDTYPE
PROCEDURE CreateTree()
.....................................................................................................................................
.....................................................................................................................................
..............................................................................................................................
..............................................................................................................................
ENDFOR
.....................................................................................................................................
ENDPROCEDURE [7]
IF FreePointer ...............................................................................................................
THEN
ELSE // add new data item to first node in the free list
NewNodePointer ← FreePointer
.................................................................................................................................
FreePointer ← .................................................................................................
Tree[NewNodePointer].LeftPointer ← ......................................................
IF ...........................................................................................................................
....................................................................................................................
Index ← RootPointer
IF Direction = "Left"
.......................................................................................................
.......................................................................................................
ENDIF
ENDIF
ENDIF
ENDPROCEDURE [8]
(e) The traverse tree operation outputs the data items in alphabetical order. This can be written
as a recursive solution.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
ENDPROCEDURE [5]
3 A programmer is writing a treasure island game to be played on the computer. The island is
a rectangular grid, 30 squares by 10 squares. Each square of the island is represented by an
element in a 2D array. The top left square of the island is represented by the array element [0, 0].
There are 30 squares across and 10 squares down.
Here is an example display after the player has chosen to dig at location [9, 3]:
..............................
..............................
..............................
..............................
..............................
........T.....................
..............................
..............................
.........T....................
...X..........................
The programmer has designed the class IslandClass. The identifier table for this class is:
(a) The programmer designed the pseudocode for the main program as follows:
CALL Island.HideTreasure()
ENDFOR
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[3]
(b) Write program code to declare the IslandClass and write the constructor method.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[5]
(c) The procedure DisplayGrid shows the current grid data. DisplayGrid makes use of the
getter method GetSquare of the Island class.
..............................
..............................
..............................
..............................
..............................
........T.....................
..............................
..............................
.........T....................
...X..........................
(i) Write program code for the GetSquare(Row, Column) getter method.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[4]
(d) Write program code for the HideTreasure method. Your method should check that the
random location generated does not already contain treasure.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[5]
(e) (i) The DigHole method takes two integers as parameters. These parameters form a valid
grid location. The location is marked with 'X' or 'O' as appropriate.
Write program code for the DigHole method. The values to represent treasure, found
treasure and hole should be declared as constants.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
Write program code for the StartDig procedure. Ensure that the user input is fully
validated.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[5]
© UCLES 2017 9608/42/M/J/17
471
17
(f) (i) The squares in the IslandClass grid could have been declared as objects of a
Square class.
State the term used to describe the relationship between IslandClass and Square.
...........................................................................................................................................
.......................................................................................................................................[1]
(ii) Draw the appropriate diagram to represent this relationship. Do not list the attributes and
methods of the classes.
[2]
BLANK PAGE
BLANK PAGE
BLANK PAGE
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.
Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.
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.
1(b) Op 6
Label Operand Comment
code
START: LDD NUMBER1 1
XOR MASK // convert to one's complement 1
INC ACC // convert to two's complement 1
STO NUMBER2 1
END
MASK: B11111111 // show value of mask in binary here 1
NUMBER1: B00000101 // positive integer
NUMBER2: B11111011 // show value of negative equivalent 1
2(c)(ii) • –1 2
• It is not the number for any node.
Data : STRING
ENDTYPE
DECLARE Tree : ARRAY[0 : 9] OF Node 1
PROCEDURE CreateTree()
DECLARE Index : INTEGER
RootPointer ← -1 1
FreePointer ← 0 1
Tree[Index].LeftPointer ← Index + 1 1
Tree[Index].RightPointer ← -1 1
ENDFOR
Tree[9].LeftPointer ← -1 1
ENDPROCEDURE
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
Tree[NewNodePointer].LeftPointer ← -1 1
ENDIF
ENDIF
ENDIF
ENDPROCEDURE
THEN
TraverseTree(Tree[Pointer].LeftPointer) 1
TraverseTree(Tree[Pointer].RightPointer) 1
ENDIF
ENDPROCEDURE
Example Python
Island = IslandClass() 1
DisplayGrid()
for Treasure in range(3):
Island.HideTreasure() 1
StartDig()
DisplayGrid() 1
Example Pascal
DisplayGrid; 1
end;
Island.HideTreasure() 1
Next
StartDig()
DisplayGrid() 1
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;
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
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
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;
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;
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
3(f)(i) containment/aggregation 1