Cambridge A Level Computer Science 9608 — 2016 Oct/Nov Paper 4 · Variant 3
9608/43/O/N/16 · 75 marks · ≈84 min
The question paper and its mark scheme, free to read here and free to download. This is Cambridge’s own paper, exactly as it was sat.
Question paper16 pages
















Mark scheme12 pages
Answers below. Sit the paper first if you are practising.












Paper as text
Question paper, page 1
This document consists of 16 printed pages. DC (ST/SW) 129124 © UCLES 2016 [Turn over Cambridge International Examinations Cambridge International Advanced Level * 9 6 5 7 8 9 7 0 4 9 * COMPUTER SCIENCE 9608/43 Paper 4 Further Problem-solving and Programming Skills October/November 2016 2 hours Candidates answer on the Question Paper. No Additional Materials are required. No calculators allowed. READ THESE INSTRUCTIONS FIRST Write your Centre number, candidate number and name in the spaces at the top of this page. Write in dark blue or black pen. You may use an HB pencil for any diagrams, graphs or rough working. Do not use staples, paper clips, glue or correction fluid. DO NOT WRITE IN ANY BARCODES. Answer all questions. No marks will be awarded for using brand names of software packages or hardware. At the end of the examination, fasten all your work securely together. The number of marks is given in brackets [ ] at the end of each question or part question. The maximum number of marks is 75.
Question paper, page 2
2 9608/43/O/N/16 © UCLES 2016 1 A user can lock a safety deposit box by inputting a 4-digit code. The user can unlock the box with the same 4-digit code. There is a keypad on the door of the safety deposit box. The following diagram shows the keys on the keypad. 1 2 3 4 5 6 7 8 9 R 0 Enter Initially, the safety deposit box door is open and the user has not set a code. The operation of the safety deposit box is as follows: A) To set a new code the door must be open. The user chooses a 4-digit code and sets it by pressing the numerical keys on the keypad, followed by the Enter key. Until the user clears this code, it remains the same. (See point E below) B) The user can only close the door if the user has set a code. C) To lock the door, the user closes the door, enters the set code and presses the Enter key. D) To unlock the door, the user enters the set code. The door then opens automatically. E) The user clears the code by opening the door and pressing the R key, followed by the Enter key. The user can then set a new code. (See point A above) The following state transition table shows the transition from one state to another of the safety deposit box: Current state Event Next state Door open, no code set 4-digit code entered Door open, code set Door open, code set R entered Door open, no code set Door open, code set Close door Door closed Door closed Set code entered Door locked Door locked Set code entered Door open, code set Door locked R entered Door locked
Question paper, page 3
3 9608/43/O/N/16 © UCLES 2016 [Turn over (a) Complete the state-transition diagram. start Door open no code set Door closed … … … … … … … … … … [7]
Question paper, page 4
4 9608/43/O/N/16 © UCLES 2016 (b) A company wants to simulate the use of a safety deposit box. It will do this with object-oriented programming (OOP). The following diagram shows the design for the class SafetyDepositBox. This includes the properties and methods. SafetyDepositBox Code : STRING // 4 digits State : STRING // "Open-NoCode", "Open-CodeSet", "Closed" // or "Locked" Create() // method to create and initialise an object // if using Python use __init__ Reset() // clears Code SetState() // set state to parameter value // and output new state SetNewCode() // sets Code to parameter value // output message and new code StateChange() // reads keypad and takes appropriate action Write program code for the following methods. Programming language … (i) Create() … … … … … [3] (ii) Reset() … … … [2]
Question paper, page 5
5 9608/43/O/N/16 © UCLES 2016 [Turn over (iii) SetState() … … … … [2] (iv) SetNewCode() … … … … [2] (v) The user must enter a 4-digit code. Write program code for a function Valid(s : STRING)that returns: • TRUE if the input string s consists of exactly 4 digits • FALSE otherwise Programming language … … … … … … … … … … … [4]
Question paper, page 6
6 9608/43/O/N/16 © UCLES 2016 (vi) Convert the flowchart to program code for the method StateChange(). Use the properties and methods in the original class definition and the Valid() function from part (v). METHOD StateChange INPUT Chars Is Chars = 'R'? Yes Yes No No No No No No Yes Yes Yes Is State = "Open-CodeSet"? CALL Reset() CALL SetState("Open-NoCode") Is Chars = Code? Is State = "Locked"? Is Chars = "" and State = "Open-CodeSet"? CALL SetNewCode(Chars) OUTPUT "Error – code format incorrect" ENDMETHOD OUTPUT "Error – does not match set code" No Yes Is Chars a valid 4-digit code? No Yes Is State = "Open-NoCode"? CALL SetState("Open-CodeSet") CALL SetState("Closed") CALL SetState("Open-CodeSet") Yes Is State = "Closed"? CALL SetState("Locked")
Question paper, page 7
7 9608/43/O/N/16 © UCLES 2016 [Turn over Programming language … … … … … … … … … … … … … … … … … … … … … … … … … … … …[12]
Question paper, page 8
8 9608/43/O/N/16 © UCLES 2016 (vii) The company needs to write a program to simulate a safety deposit box. The program will create an object with identifier ThisSafe, which is an instance of the class SafetyDepositBox. The main program design is: instantiate ThisSafe (create and initialise ThisSafe) loop forever (continually use ThisSafe) call StateChange() method end loop Write program code for the main program. Programming language … … … … … … … … … … … … [4]
Question paper, page 9
9 9608/43/O/N/16 © UCLES 2016 [Turn over (c) It is possible to declare properties and methods as either public or private. The programmer has modified the class design for SafetyDepositBox as follows: SafetyDepositBox PRIVATE Code : STRING State : STRING PUBLIC Create() StateChange() PRIVATE Reset() SetState() SetNewCode() (i) Describe the effects of declaring the SafetyDepositBox properties as private. … … … … [2] (ii) Describe the effects of declaring two methods of the class as public and the other three as private. … … … … [2]
Question paper, page 10
10 9608/43/O/N/16 © UCLES 2016 2 Circle the programming language that you have studied: Visual Basic (console mode) Python Pascal Delphi (console mode) (a) (i) Name the programming environment you have used when typing in program code. … … List three features of the editor that helped you to write program code. 1 … … 2 … … 3 … … [3] (ii) Explain when and how your programming environment reports a syntax error. When … … … How … … … [2]
Question paper, page 11
11 9608/43/O/N/16 © UCLES 2016 [Turn over Question 2 continues on page 12.
Question paper, page 12
12 9608/43/O/N/16 © UCLES 2016 (iii) The table shows a module definition for BinarySearch in three programming languages. Study one of the examples. Indicate your choice by circling A, B or C: A B C A) Python 01 02 03 04 05 06 07 08 09 10 11 def BinarySearch(List, Low, High, SearchItem): Index = -1 while (Index == -1) AND (Low <= High): Middle = (High + Low) // 2 if List[Middle] == SearchItem: Index = Middle elif List[Middle] < SearchItem: Low = Middle + 1 else: High = Middle - 1 return(Middle) B) Pascal/Delphi 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 FUNCTION BinarySearch(VAR List : ARRAY OF INTEGER; Low, High, SearchItem : INTEGER) : INTEGER; VAR Index, Middle : INTEGER; BEGIN Index := -1; WHILE (Index = -1) & (Low <= High) DO BEGIN Middle := (High + Low) DIV 2; IF List[Middle] = SearchItem THEN Index := Middle ELSE IF List[Middle] < SearchItem THEN Low := Middle + 1 ELSE High := Middle - 1; END; Result := Middle; END; C) Visual Basic 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 Function BinarySearch(ByRef List() As Integer, ByVal Low As Integer, ByVal High As Integer, ByVal SearchItem As Integer) As Integer Dim Index, Middle As Integer Index = -1 Do While (Index = -1) & (Low <= High) Middle = (High + Low) \ 2 If List(Middle) = SearchItem Then Index = Middle ElseIf List(Middle) < SearchItem Then Low = Middle + 1 Else High = Middle - 1 End If Loop BinarySearch = Middle End Function
Question paper, page 13
13 9608/43/O/N/16 © UCLES 2016 [Turn over The programming environment reported a syntax error in the BinarySearch code. State the line number: … Write the correct code for this line. …[2] (b) (i) State whether programs written in your programming language are compiled or interpreted. … … [1] (ii) A programmer corrects the syntax error and tests the function. It does not perform as expected when the search item is not in the list. State the type of error: … Write down the line number where the error occurs. … Write the correct code for this line. …[2] (iii) State the programming environment you have used when debugging program code. … … Name two debugging features and describe how they are used. 1 … … … … 2 … … … … [4]
Question paper, page 14
14 9608/43/O/N/16 © UCLES 2016 3 The following table shows part of the instruction set for a processor which has one general purpose register, the Accumulator (ACC), and an index register (IX). Instruction 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. LDX <address> Indexed addressing. Form the address from <address> + the contents of the index register. Copy the contents of this calculated address to ACC. LDR #n Immediate addressing. Load the number n into IX. STO <address> Store the contents of ACC at the given address. INC <register> Add 1 to the contents of the register (ACC or IX). DEC <register> Subtract 1 from the contents of the register (ACC or IX). CMP <address> Compare the contents of ACC with the contents of <address>. CMP #n Compare the contents of ACC with number n. JPE <address> Following a compare instruction, jump to <address> if the compare was True. JPN <address> Following a compare instruction, jump to <address> if the compare was False. OUT Output to the screen the character whose ASCII value is stored in ACC. END Return control to the operating system. A programmer is writing a program that outputs a string, first in its original order and then in reverse order. The program will use locations starting at address NAME to store the characters in the string. The location with address MAX stores the number of characters that make up the string. The programmer has started to write the program in the table opposite. The Comment column contains descriptions for the missing program instructions. Complete the program using op codes from the given instruction set.
Question paper, page 15
15 9608/43/O/N/16 © UCLES 2016 [Turn over Label Op code Operand Comment START: // initialise index register to zero // initialise COUNT to zero LOOP1: // load character from indexed address NAME // output character to screen // increment index register // increment COUNT starts here // is COUNT = MAX ? // if FALSE, jump to LOOP1 REVERSE: // decrement index register // set ACC to zero // store in COUNT LOOP2: // load character from indexed address NAME // output character to screen // decrement index register // increment COUNT starts here // is COUNT = MAX ? // if FALSE, jump to LOOP2 // end of program COUNT: MAX: 4 NAME: B01000110 // ASCII code in binary for 'F' B01010010 // ASCII code in binary for 'R' B01000101 // ASCII code in binary for 'E' B01000100 // ASCII code in binary for 'D' [15]
Question paper, page 16
16 9608/43/O/N/16 © UCLES 2016 Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the publisher will be pleased to make amends at the earliest possible opportunity. To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after the live examination series. Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge. 4 Commercial software usually undergoes acceptance testing and integration testing. Distinguish between the two types of testing by stating: • who does the testing • when the testing occurs • the specific purpose of each type of testing (i) Acceptance testing Who … … When … … Purpose … …[3] (ii) Integration testing Who … … When … … Purpose … …[3]
Mark scheme, page 1
® IGCSE is the registered trademark of Cambridge International Examinations. This document consists of 12 printed pages. © UCLES 2016 [Turn over Cambridge International Examinations Cambridge International Advanced Level COMPUTER SCIENCE 9608/43 Paper 4 Written Paper October/November 2016 MARK SCHEME Maximum Mark: 75 Published This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the details of the discussions that took place at an Examiners’ meeting before marking began, which would have considered the acceptability of alternative answers. Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for Teachers. Cambridge will not enter into discussions about these mark schemes. Cambridge is publishing the mark schemes for the October/November 2016 series for most Cambridge IGCSE®, Cambridge International A and AS Level components and some Cambridge O Level components.
Mark scheme, page 2
Page 2 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 43 © UCLES 2016 1 (a) 1 mark for both Set code entered correct. 1 mark for each label. [7] (b) (i) 1 mark per bullet to max 3 [3] • Method header • initialising Code to "" • initialising State to "Open-NoCode" e.g. PYTHON: def __init__(self): self.__code = "" self.__state = "Open-NoCode" PASCAL/DELPHI: constructor SafetyDepositBox.Create(); begin Code := ''; State := 'Open-NoCode'; end;
Mark scheme, page 3
Page 3 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 43 © UCLES 2016 VB: Public Sub New() Code = "" State = "Open-NoCode" End Sub (ii) 1 mark per bullet to max 2 [2] • method header • Setting code to "" e.g. PYTHON: def reset(self): self.__code = "" PASCAL/DELPHI: procedure SafetyDepositBox.Reset(); begin Code := ''; end; VB: Public Sub Reset() Code = "" End Sub (iii) 1 mark per bullet to max 2 [2] • method header with parameter • setting state to parameter value • Outputting state e.g. PYTHON: def SetState(self,NewState): self.__state = NewState print(self.__state) PASCAL/DELPHI: Procedure SetState(NewState : String); begin State := NewState WriteLn(State) end;
Mark scheme, page 4
Page 4 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 43 © UCLES 2016 VB: VB: Public Sub SetState(ByVal NewState As String) State = NewState Console.WriteLine(State) End Sub Private _State As String Public Property State() As String Get Return _State End Get Set(value As String) _State = value End Set End Property Public Sub SetState() Console.WriteLine(Me.State) End Sub (iv) 1 mark per bullet to max 2 [2] • setting code to parameter • Outputting New cost set and code e.g. PYTHON: def SetNewCode(self, NewCode): self.__code = NewCode print("New code set: ", self.__code) PASCAL/DELPHI: procedure SetNewCode(NewCode : String); begin Code := NewCode; WriteLn('New code set: ', Code) end; VB: Public Sub SetNewCode(NewCode) Code = NewCode Console.WriteLine("New code set: " & Code) End Sub
Mark scheme, page 5
Page 5 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 43 © UCLES 2016 (v) 1 mark per bullet to max 4 [4] • function header taking string parameter, returns Boolean • check length of string is 4 • check each character is a digit • return of correct Boolean value for both cases e.g PYTHON: def __valid(self, s): digits = ['0','1','2','3','4','5','6','7','8','9'] isValid = False if (len(s) == 4): if (s[0] in digits) & (s[1] in digits) & (s[2] in digits) & (s[3] in digits): isValid = True return(isValid) PASCAL/DELPHI: function Valid(s : string) : Boolean; var isValid : Boolean; i : integer; begin isValid := False if Length(s) = 4 then begin isValid := True; For i := 1 to 4 do if (s[i] < '0') OR (s[i] > '9') then isValid := False; end; end; VB: ByVal optional Public Function valid(ByVal s As String) As Boolean If s Like "####" Then Return True Else Return False End If End Function
Mark scheme, page 6
Page 6 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 43 © UCLES 2016 (vi) 1 mark per bullet to max 12 [12] • read Chars from keyboard • check if ‘R’ and state = Open-CodeSet • call method Reset() & method SetState • if Chars is the set code: • check if locked • set state to Open-CodeSet • else if closed • then set state to Locked • if Chars is empty and State is “Open-CodeSet” then setState to closed • if Chars is a valid 4-digit code and state is Open-NoCode • call setNewCode and SetState • outputting correct error messages for not valid 4-digit and state is not Open-NoCode e.g. PYTHON: def StateChange(self): Chars = input("Enter code: ") if Chars == "R": if self.__state == "Open-CodeSet": self.reset() self.SetState("Open-NoCode") elif Chars == self.__code: if self.__state == "Locked": self.SetState("Open-CodeSet") elif self.__state == "Closed": self.SetState("Locked") elif (Chars == "") & (self.__state == "Open-CodeSet"): self.SetState("Closed") elif self.__valid(Chars): if self.__state == "Open-NoCode": self.SetNewCode(Chars) self.SetState("Open-CodeSet") else: print("Error - does not match set code") else: print("Error - Code format incorrect")
Mark scheme, page 7
Page 7 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 43 © UCLES 2016 PASCAL/DELPHI: Procedure StateChange(); var Chars : String; begin ReadLn(Chars); If Chars = 'R' Then If State = 'Open-CodeSet' Then begin Reset(); SetState('Open-NoCode'); end Else If Chars = Code Then If state = 'Locked' Then SetState('Open-CodeSet') Else If state = 'Closed' Then SetState('Locked') Else If (Chars = '') AND (State = 'Open-CodeSet') Then SetState('Closed') Else If Valid(Chars) Then begin If State == 'Open-NoCode' Then begin SetNewCode(Chars); SetState('Open-CodeSet'); end else WriteLn('Error - does not match set code') end Else WriteLn('Error - Code format incorrect'); end;
Mark scheme, page 8
Page 8 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 43 © UCLES 2016 VB: Public Sub StateChange() Dim Chars As String Chars = Console.ReadLine() If Chars = "R" Then If State = "Open-CodeSet" Then Reset() SetState("Open-NoCode") End If ElseIf Chars = Code Then If state = "Locked" Then SetState("Open-CodeSet") ElseIf state = "Closed" Then SetState("Locked") End If ElseIf (Chars = "") AND (State = "Open-CodeSet") Then SetState("Closed") ElseIf Valid(Chars) Then If State == "Open-NoCode" Then SetNewCode(Chars) SetState("Open-CodeSet") Else Console.WriteLine("Error - does not match set code") End If Else Console.WriteLine("Error - Code format incorrect") End If End Sub (vii) 1 mark per bullet to max 4 [4] • method header • Initialising ThisSafe to instance of SafetyDepositBox • Loop forever • Call method StateChange on ThisSafe e.g. PYTHON: def main(): ThisSafe = SafetyDepositBox() while True: ThisSafe.StateChange() PASCAL/DELPHI: var ThisSafe : SafetyDepositBox; ThisSafe := SafetyDepositBox.Create; while True do ThisSafe.StateChange;
Mark scheme, page 9
Page 9 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 43 © UCLES 2016 VB: Sub Main() Dim ThisSafe As New SafetyDepositBox() Do ThisSafe.StateChange() Loop End Sub (c) (i) 1 mark per bullet to max 2: [2] • The attributes can only be accessed in the class • Properties are needed to get/set the data // It provides/uses encapsulation • Increase security/integrity of attributes (ii) 1 mark per bullet [2] • The public methods can be called anywhere in the main program // Public methods can be inherited by sub-classes • The private methods can only be called within the class definition // cannot be called outside the class definition // Private methods cannot be inherited by sub-classes 2 (a) (i) 1 mark per feature to max 3 [3] e.g. • auto-indent • auto-complete / by example • colour-coded keywords/ strings/ comments/ built-in functions/ user-defined function names • pop-up help • can set indent width • expand/collapse subroutines/code • block highlighting incorrect syntax highlighting/underlining //dynamic syntax checker (ii) Read and mark the answer as one paragraph. Mark a 'how' and a 'when' anywhere in the answer. [2] 1 mark for when, 1 mark for how. e.g. When: • the error has been typed • when the program is being run/compiled/interpreted How: • highlights/underlines displays error message/pop-up (iii) A B C Line 3 Line 5 Line 4 [1] while (Index == -1) & (Low <= High): WHILE (Index = -1) AND (Low <= High) DO DO WHILE (Index = - 1) AND (Low <= High) [1]
Mark scheme, page 10
Page 10 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 43 © UCLES 2016 (b) (i) Python: compiled/interpreted [1] VB.NET: compiled Pascal: compiled/interpreted Delphi: compiled/interpreted (ii) Logic error Logic error Logic error [1] 11 return(Index) 14 Result := Index; 14 BinarySearch = Index [1] (iii) 1 mark for each name, 1 for each description [4] • breakpoint • a point where the program can be halted to see if the program works at this point • stepping / step through • executes one statement at a time and then pauses to see the effect of each statement • variable watch window • observe how variables changed during execution
Mark scheme, page 11
Page 11 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 43 © UCLES 2016 3 START: LDR #0 // initialise index register to zero [1] LDM #0 // initialise COUNT to zero [1] STO COUNT LOOP1: LDX NAME // load character from indexed address NAME [1] OUT // output character to screen [1] INC IX // increment index register [1] LDD COUNT // increment COUNT starts here [1] INC ACC STO COUNT CMP MAX // is COUNT = MAX? [1] JPN LOOP1 // if FALSE, jump to LOOP1 [1] REVERSE: DEC IX // decrement index register [1] LDM #0 // set ACC to zero [1] STO COUNT // store in COUNT LOOP2: LDX NAME // load character from indexed address NAME [1] OUT // output character to screen DEC IX // decrement index register [1] LDD COUNT // increment COUNT starts here [1] INC ACC // STO COUNT // CMP MAX // is COUNT = MAX? [1] JPN LOOP2 // if FALSE, jump to LOOP2 END // end of program [1] COUNT: MAX: 4 NAME: B01000110 // ASCII code in binary for 'F' B01010010 // ASCII code in binary for 'R' B01000101 // ASCII code in binary for 'E' B01000100 // ASCII code in binary for 'D' [Max 15]
Mark scheme, page 12
Page 12 Mark Scheme Syllabus Paper Cambridge International A Level – October/November 2016 9608 43 © UCLES 2016 4 Acceptance testing Integration testing Who The end user // user of the software The programmer / in-house testers [1] + [1] When When the software is finished/ when it is installed When the separate modules have been written and tested [1] + [1] Purpose To ensure the software is what the customer ordered // to check that the software meets the user requirements To ensure the modules work together as expected [1] + [1]
What you needed in this session
Cambridge’s own grade thresholds for 2016 Oct/Nov, Paper 4 · Variant 3. A higher threshold means an easier paper — the bar moves with how the cohort did.