Cambridge A Level Computer Science 9608 — 2016 May/June Paper 4 · Variant 1

9608/41/M/J/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.

← All Computer Science papersWhat was in this paper?

Question paper20 pages

Cambridge A Level Computer Science 9608 2016 May/June Paper 4 · Variant 1 question paper, page 1 of 20
Page 1 of 20
Cambridge A Level Computer Science 9608 2016 May/June Paper 4 · Variant 1 question paper, page 2 of 20
Page 2 of 20
Cambridge A Level Computer Science 9608 2016 May/June Paper 4 · Variant 1 question paper, page 3 of 20
Page 3 of 20
Cambridge A Level Computer Science 9608 2016 May/June Paper 4 · Variant 1 question paper, page 4 of 20
Page 4 of 20
Cambridge A Level Computer Science 9608 2016 May/June Paper 4 · Variant 1 question paper, page 5 of 20
Page 5 of 20
Cambridge A Level Computer Science 9608 2016 May/June Paper 4 · Variant 1 question paper, page 6 of 20
Page 6 of 20
Cambridge A Level Computer Science 9608 2016 May/June Paper 4 · Variant 1 question paper, page 7 of 20
Page 7 of 20
Cambridge A Level Computer Science 9608 2016 May/June Paper 4 · Variant 1 question paper, page 8 of 20
Page 8 of 20
Cambridge A Level Computer Science 9608 2016 May/June Paper 4 · Variant 1 question paper, page 9 of 20
Page 9 of 20
Cambridge A Level Computer Science 9608 2016 May/June Paper 4 · Variant 1 question paper, page 10 of 20
Page 10 of 20
Cambridge A Level Computer Science 9608 2016 May/June Paper 4 · Variant 1 question paper, page 11 of 20
Page 11 of 20
Cambridge A Level Computer Science 9608 2016 May/June Paper 4 · Variant 1 question paper, page 12 of 20
Page 12 of 20
Cambridge A Level Computer Science 9608 2016 May/June Paper 4 · Variant 1 question paper, page 13 of 20
Page 13 of 20
Cambridge A Level Computer Science 9608 2016 May/June Paper 4 · Variant 1 question paper, page 14 of 20
Page 14 of 20
Cambridge A Level Computer Science 9608 2016 May/June Paper 4 · Variant 1 question paper, page 15 of 20
Page 15 of 20
Cambridge A Level Computer Science 9608 2016 May/June Paper 4 · Variant 1 question paper, page 16 of 20
Page 16 of 20
Cambridge A Level Computer Science 9608 2016 May/June Paper 4 · Variant 1 question paper, page 17 of 20
Page 17 of 20
Cambridge A Level Computer Science 9608 2016 May/June Paper 4 · Variant 1 question paper, page 18 of 20
Page 18 of 20
Cambridge A Level Computer Science 9608 2016 May/June Paper 4 · Variant 1 question paper, page 19 of 20
Page 19 of 20
Cambridge A Level Computer Science 9608 2016 May/June Paper 4 · Variant 1 question paper, page 20 of 20
Page 20 of 20

Mark scheme15 pages

Answers below. Sit the paper first if you are practising.

Mark scheme, page 1 of 15
Page 1 of 15
Mark scheme, page 2 of 15
Page 2 of 15
Mark scheme, page 3 of 15
Page 3 of 15
Mark scheme, page 4 of 15
Page 4 of 15
Mark scheme, page 5 of 15
Page 5 of 15
Mark scheme, page 6 of 15
Page 6 of 15
Mark scheme, page 7 of 15
Page 7 of 15
Mark scheme, page 8 of 15
Page 8 of 15
Mark scheme, page 9 of 15
Page 9 of 15
Mark scheme, page 10 of 15
Page 10 of 15
Mark scheme, page 11 of 15
Page 11 of 15
Mark scheme, page 12 of 15
Page 12 of 15
Mark scheme, page 13 of 15
Page 13 of 15
Mark scheme, page 14 of 15
Page 14 of 15
Mark scheme, page 15 of 15
Page 15 of 15

Paper as text

Question paper, page 1

This document consists of 19 printed pages and 1 blank page. DC (NH/SG) 106699/3 © UCLES 2016 [Turn over * 7 9 0 6 0 4 9 1 7 9 * COMPUTER SCIENCE 9608/41 Paper 4 Further Problem-solving and Programming Skills May/June 2016 2 hours Candidates answer on the Question Paper. No Additional Materials are required. No calculators allowed. READ THESE INSTRUCTIONS FIRST Write your Centre number, candidate number and name in the spaces at the top of this page. Write in dark blue or black pen. You may use an HB pencil for any diagrams, graphs or rough working. Do not use staples, paper clips, glue or correction fluid. DO NOT WRITE IN ANY BARCODES. Answer all questions. No marks will be awarded for using brand names of software packages or hardware. At the end of the examination, fasten all your work securely together. The number of marks is given in brackets [ ] at the end of each question or part question. The maximum number of marks is 75. Cambridge International Examinations Cambridge International Advanced Level

Question paper, page 2

2 9608/41/M/J/16 © UCLES 2016 1 A linked list abstract data type (ADT) is to be used to store and organise surnames. This will be implemented with a 1D array and a start pointer. Elements of the array consist of a user-defined type. The user-defined type consists of a data value and a link pointer. Identifier Data type Description LinkedList RECORD User-defined type Surname STRING Surname string Ptr INTEGER Link pointers for the linked list (a) (i) Write pseudocode to declare the type LinkedList. … … … …[3] (ii) The 1D array is implemented with an array SurnameList of type LinkedList. Write the pseudocode declaration statement for SurnameList. The lower and upper bounds of the array are 1 and 5000 respectively. …[2] (b) The following surnames are organised as a linked list with a start pointer StartPtr. StartPtr: 3 1 2 3 4 5 6 5000 Surname Liu Yang Chan Wu Zhao Huang … Ptr 4 5 6 2 0 1 … State the value of the following: (i) SurnameList[4].Surname …[1] (ii) SurnameList[StartPtr].Ptr …[1]

Question paper, page 3

3 9608/41/M/J/16 © UCLES 2016 [Turn over (c) Pseudocode is to be written to search the linked list for a surname input by the user. Identifier Data type Description ThisSurname STRING The surname to search for Current INTEGER Index to array SurnameList StartPtr INTEGER Index to array SurnameList. Points to the element at the start of the linked list (i) Study the pseudocode in part (c)(ii). Complete the table above by adding the missing identifier details. [2] (ii) Complete the pseudocode. 01 Current ← … 02 IF Current = 0 03 THEN 04 OUTPUT … 05 ELSE 06 IsFound ← … 07 INPUT ThisSurname 08 REPEAT 09 IF … = ThisSurname 10 THEN 11 IsFound ← TRUE 12 OUTPUT "Surname found at position ", Current 13 ELSE 14 // move to the next list item 15 … 16 ENDIF 17 UNTIL IsFound = TRUE OR … 18 IF IsFound = FALSE 19 THEN 20 OUTPUT "Not Found" 21 ENDIF 22 ENDIF [6]

Question paper, page 4

4 9608/41/M/J/16 © UCLES 2016 2 (a) (i) State what is meant by a recursively defined procedure. … …[1] (ii) Write the line number from the pseudocode shown in part (b) that shows the procedure X is recursive. … [1] (b) The recursive procedure X is defined as follows: 01 PROCEDURE X(Index, Item) 02 IF MyList[Index] > 0 03 THEN 04 IF MyList(Index) >= Item 05 THEN 06 MyList[Index] ← MyList[Index + 1] 07 ENDIF 08 CALL X(Index + 1, Item) 09 ENDIF 10 ENDPROCEDURE An array MyList is used to store a sorted data set of non-zero integers. Unused cells contain zero. 1 2 3 4 5 6 7 8 9 10 MyList 3 5 8 9 13 16 27 0 0 0

Question paper, page 5

5 9608/41/M/J/16 © UCLES 2016 [Turn over (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]

Question paper, page 6

6 9608/41/M/J/16 © UCLES 2016 3 A car hire company hires cars to customers. Each time a car is hired, this is treated as a transaction. For each transaction, the following data are stored. For the customer: • customer name • ID number For the hire: • car registration • hire start date • number of days hired The transaction data are stored in a text file HIRE-TRANS. The file is made up of a file body, F_BODY, and a file trailer, F_TRAILER. F_BODY has one transaction, TRANS, on each line. (a) The first step in Jackson Structured Programming (JSP) design is to produce a JSP data structure diagram. Complete the following JSP data structure diagram. HIRE-TRANS F_BODY * [7]

Question paper, page 7

7 9608/41/M/J/16 © UCLES 2016 [Turn over (b) The computer system will produce many printed reports. One report is CAR_REPORT. This displays all hire data for all cars. For each car, the following data are displayed: • the car data • a list of all the hires • the total number of hires A car with zero hires is not included on the report. Complete the following CAR_REPORT JSP data structure diagram. CAR_REPORT HIRE_LIST HIRE CAR No hires One or more hires * [5]

Question paper, page 8

8 9608/41/M/J/16 © UCLES 2016 4 When a car reaches a certain age, a safety assessment has to be carried out. A car’s brakes and tyres must be tested. The tyre test result and the brakes test result for each car are recorded. If the car passes the assessment, a safety certificate is issued. Cars have a unique three-character registration. The following knowledge base is used: 01 car(a05). 02 car(h04). 03 car(a03). 04 car(h07). 05 car(a23). 06 car(p05). 07 car(b04). 08 carRegYear(a05, 2015). 09 carRegYear(h04, 2013). 10 carRegYear(a03, 2008). 11 carRegYear(h07, 2011). 12 carRegYear(a23, 2008). 13 carRegYear(p05, 2014). 14 carRegYear(b04, 2014). 15 testBrakes(h07, pass). 16 testTyres(h07, fail). 17 testBrakes(a03, fail). 18 testTyres(a03, fail). 19 testBrakes(a23, pass). 20 testTyres(a23, pass). 21 carAssessmentDue if carRegYear(Car, RegYear) and RegYear <= DeadlineYear. 22 issueCertificate(Car) if testTyres(Car, Result) and testBrakes(Car, Result) and Result = pass. (a) (i) DeadlineYear is assigned value 2011. Identify the car registrations for cars which are due to be tested. …[1] (ii) State how clause 22 determines whether or not a safety certificate will be issued. … …[1]

Question paper, page 9

9 9608/41/M/J/16 © UCLES 2016 [Turn over (b) If a car fails one of the two tests, a retest is allowed. Write a new rule for this. retestAllowed(…) if … … …[3] (c) Logic programming uses a data structure called a list. A new fact is added to the knowledge base. 23 carList = [a03,p05,b04,h04,h07,a23]. The following notation and operators are to be used with a list: [X|Y] denotes a list with: • X the first list element • Y the list consisting of the remaining list elements [] denotes an empty list (i) The list [a07,p03] is denoted by [A|B] State the value of A and B. A = … B = … [2] (ii) The lists [c03,d02,n05|C] and [c03,d02,n05,p05,m04] are identical. State the value of C. C = … [1] (iii) The list [a06,a02] is denoted by [D,E|F] State the value of F. F = … [1]

Question paper, page 10

10 9608/41/M/J/16 © UCLES 2016 (d) The predicate conCatCompare is defined as a rule and returns TRUE or FALSE as follows: conCatCompare(X, Y, Z) Concatenates the lists X and Y and compares the new list with list Z. If equal, the clause evaluates to TRUE, otherwise FALSE. Consider the clause: conCatCompare(X, Y, [a7,b6,c4]) If: • the clause evaluates to TRUE • and Y represents the list [a7, b6, c4] State the value of X. X = …[1]

Question paper, page 11

11 9608/41/M/J/16 © UCLES 2016 [Turn over 5 (a) A program calculates the exam grade awarded from a mark input by the user. The code is written as a function CalculateGrade. The function: • has a single parameter Mark of INTEGER data type • returns the grade awarded Grade of STRING data type The logic for calculating the grade is as follows: Mark Grade Under 40 FAIL 40 and over and under 55 PASS 55 and over and under 70 MERIT 70 and over DISTINCTION The programmer designs the following table for test data: Mark Description Expected result (Grade) Normal Abnormal Extreme/Boundary (i) Complete the table above. [3] (ii) State why this table design is suitable for black box testing. … …[1]

Question paper, page 12

12 9608/41/M/J/16 © UCLES 2016 (b) When designing and writing program code, explain what is meant by: • an exception • exception handling … … … … … …[3] (c) A program is to be written to read a list of exam marks from an existing text file into a 1D array. Each line of the file stores the mark for one student. State three exceptions that a programmer should anticipate for this program. 1 … … 2 … … 3 … …[3]

Question paper, page 13

13 9608/41/M/J/16 © UCLES 2016 [Turn over (d) The following pseudocode is to read two numbers: 01 DECLARE Num1 : INTEGER 02 DECLARE Num2 : INTEGER 03 DECLARE Answer : INTEGER 04 TRY 05 OUTPUT "First number..." 06 INPUT Num1 07 OUTPUT "Second number..." 08 INPUT Num2 09 Answer ← Num1 / (Num2 – 6) 10 OUTPUT Answer 11 EXCEPT ThisException : EXCEPTION 12 OUTPUT ThisException.Message 13 FINALLY 14 // remainder of the program follows … 29 30 ENDTRY The programmer writes the corresponding program code. A user inputs the number 53 followed by 6. The following output is produced: First number...53 Second number...6 Arithmetic operation resulted in an overflow (i) State the pseudocode line number which causes the exception to be raised. … [1] (ii) Explain the purpose of the pseudocode on lines 11 and 12. … … … … … …[3]

Question paper, page 14

14 9608/41/M/J/16 © UCLES 2016 6 In a board game, one player has white pieces and the other player has black pieces. Players take alternate turns to move one of their pieces. White always makes the first move. The game ends if: • a player is unable to make a move when it is their turn. In this case, there is no winner. This is called ‘stalemate’. • a player wins the game as a result of their last move and is called a ‘winner’. (a) A state-transition diagram is drawn to clarify how the game is played. Complete the following state-transition diagram. WHITE WINS BLACK moves No move possible :+,7(·6 TURN %/$&.·6 TURN Winning move BLACK WINS Stalemate [4] (b) The layout of the board at the start of the game is shown below: 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 y x

Question paper, page 15

15 9608/41/M/J/16 © UCLES 2016 [Turn over The programmer decides to use a 2D array to represent the board. The index numbering to be used is as shown. Each square on the board is either occupied by one piece only, or is empty. The data stored in the array indicate whether or not that square is occupied, and if so, with a black piece or a white piece. (i) Write program code to initialise the contents of the array to represent the board at the start of the game. Use characters as follows for each square: 'B' represents a black piece 'W' represents a white piece 'E' represents an empty square Visual Basic and Pascal: You should include the declaration statements for variables. Python: You should show a comment statement for each variable used with its data type. Programming language … … … … … … … … … … … … … … … … … … …[4]

Question paper, page 16

16 9608/41/M/J/16 © UCLES 2016 (ii) When a piece is to be moved, a procedure will calculate and output the possible destination squares for the moving piece. A piece can move one or more squares, in the x or y direction, from its current position. This will be a move: • either to an empty square, with no occupied squares on the way • or to a square containing a piece belonging to another player, with no occupied squares on the way. The other player’s piece is then removed. For example, for the circled black piece there are nine possible destination squares. Each of the two destination squares contains a white piece which would be removed. 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 y x The program requires a procedure ValidMoves. It needs three parameters: • PieceColour – colour of the moving piece • xCurrent – current x position • yCurrent – current y position The procedure will calculate all possible destination squares in the x direction only. Example output for the circled black piece is: Possible moves are: Moving LEFT 3 4 2 4 REMOVE piece Moving RIGHT 5 4 6 4 7 4 Write program code for procedure ValidMoves with the following procedure header: PROCEDURE ValidMoves(PieceColour : CHAR, xCurrent : INTEGER, yCurrent : INTEGER).

Question paper, page 17

17 9608/41/M/J/16 © UCLES 2016 [Turn over Visual Basic and Pascal: You should include the declaration statements for variables. Python: You should show a comment statement for each variable used with its data type. Programming language … … … … … … … … … … … … … … … … … … … … … … … … … … …

Question paper, page 18

18 9608/41/M/J/16 © UCLES 2016 … … … … … … … … … … … … … … … … … …[5]

Question paper, page 19

19 9608/41/M/J/16 © UCLES 2016 (c) The problem is well suited to an object-oriented design followed by object-oriented programming. (i) Describe how classes and objects could be used in this problem. … … … … …[2] (ii) For a class you identified in part(c)(i), state two properties and two methods. Class … Properties 1 … 2 … Methods 1 … 2 … [2]

Question paper, page 20

20 9608/41/M/J/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. BLANK PAGE

Mark scheme, page 1

® IGCSE is the registered trademark of Cambridge International Examinations. This document consists of 15 printed pages. © UCLES 2016 [Turn over Cambridge International Examinations Cambridge International Advanced Level COMPUTER SCIENCE 9608/41 Paper 4 Written Paper May/June 2016 MARK SCHEME Maximum Mark: 75 Published This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the details of the discussions that took place at an Examiners’ meeting before marking began, which would have considered the acceptability of alternative answers. Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for Teachers. Cambridge will not enter into discussions about these mark schemes. Cambridge is publishing the mark schemes for the May/June 2016 series for most Cambridge IGCSE®, Cambridge International A and AS Level components and some Cambridge O Level components.

Mark scheme, page 2

Q 1 Qu P es (a) (b) (c) Pag tio ) ( (i ) ( (i ) ( ge on (i) ii) (i) ii) (i) 2 TY (D (D EN Ac Li Su Pt EN Ac TY Su Pt EN Ac ST (D (D EN Ac (D Ac Ac Ac Ind Wu Ac 6 Is BO YPE DEC DEC NDT cce ink urn tr NDR cce YPE urn tr NDT cce TRU DEC DEC NDS cce DEC cce cce cce dex u cce sFo OOL E L CLA CLA TYP ept ked nam : REC ept E L nam : TYP ept UCT CLA CLA STR ept CLA ept ept ept x s ept oun LEA C Lin ARE ARE PE t: dL me IN COR t: Lin me IN PE t: TUR ARE ARE RU AS ARE AS ( wi sep wi nd AN Cam nk E) E) is : NT RD nk : NT / RE E) E) CT S / E) S / ) i tho para th + mb ked S P t S EG D ked S EG E L S P UR / O S / O nst out ato qu rel brid dLi Sur Ptr : STR GER dLi STR GER END Lin Sur Ptr RE OF Sur OF tea t lo or c ote ev dge ist rna r : RE RIN R ist RIN R DRE nke rna r : in rna in ad we can es ant e In © t ame : I ECO NG t = NG ECO edL ame : I nste ame nste of er b n be t d nte Ca e IN OR = OR Li e IN ea eL ea [] bou e , es ern amb : TE D RE D st : TE d o is d o und , crip M nati brid ST EGE ECO t ST EGE of st[ of d : ptio Mar ion dge TRI ER ORD TRI ER : [1: : .. on k S nal e In ING D ING :50 . Sch A nter G G 000 hem Le rnat A 0] me eve tion An : e el – nal nsw L – M Ex wer Lin May xam r nke y/J mina edL Jun atio Li ne ons st 20 s 20 t 16 016 6 6 Syl 9 llab 960 bu 08 s P 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Pa 4 pe 41 er Mark 3 2 1 1 2 ks

Mark scheme, page 3

Page 3 Mark Scheme Syllabus Paper Cambridge International A Level – May/June 2016 9608 41 © Cambridge International Examinations 2016 Question Answer Marks (ii) Accept () instead of [] 01 Current ← StartPtr 02 IF Current = 0 03 THEN 04 OUTPUT "Empty List" (or similar message) (accept without quotes) Reject “Error” 05 ELSE 06 IsFound ← FALSE 07 INPUT ThisSurname 08 REPEAT 09 IF SurnameList[Current].Surname = ThisSurname 10 THEN 11 IsFound ← TRUE 12 OUTPUT "Surname found at position ", Current 13 ELSE 14 // move to the next list item 15 Current ← SurnameList[Current].Ptr 16 ENDIF 17 UNTIL IsFound = TRUE OR Current = 0 18 IF IsFound = FALSE 19 THEN 20 OUTPUT "Not Found" 21 ENDIF 22 ENDIF 6 Accept = for assignment 2 (a) (i) A procedure which is defined in terms of itself // A procedure which makes a call to itself // A procedure that calls itself 1 (ii) 08 // 8 1

Mark scheme, page 4

Page 4 Mark Scheme Syllabus Paper Cambridge International A Level – May/June 2016 9608 41 © Cambridge International Examinations 2016 Question Answer Marks (b) (i) MyList Index Item 1 2 3 4 5 6 7 8 9 10 1 9 3 5 8 9 13 16 27 0 0 0 2 3 4 13 5 16 6 27 7 0 8 Note: Final mark only if no additional entries in table Accept last row to show all final values 4 (ii) Any one from: Deletes/removes parameter value/ Item (from the array MyList) // Deletes the first entry (in MyList) that equals or is bigger than Item Overwrites Item by moving subsequent items up/down/across/left R right 1

Mark scheme, page 5

Page 5 Mark Scheme Syllabus Paper Cambridge International A Level – May/June 2016 9608 41 © Cambridge International Examinations 2016 Question Answer Marks 3 (a) F_BODY F_TRAILER HIRE-TRANS Customer data Hire data CustomerID Customer Name Car Reg Hire start date Number of days hired TRANS Mark as follows: Label F_TRAILER 1 Label TRANS 1 Customer box (Accept label Customer) 1 Hire box (Accept label Hire) 1 Customer fields : Customer Name, CustomerID/IDnumber 1 Hire fields: Car Reg 1 Hire fields: Hire start date, Number of days hired 1 accept level 5 fields in any order Ignore parent 7

Mark scheme, page 6

Page 6 Mark Scheme Syllabus Paper Cambridge International A Level – May/June 2016 9608 41 © Cambridge International Examinations 2016 Question Answer Marks (b) Mark as follows: Selection symbol x 2 (Car-hire / No car-hire) 1 Labelling for CAR_HIRE / NO_HIRE (accept similar labels*) 1 Labelling for Car registration and Car total / Total hires 1 Iteration symbol for HIRE (accept in HIRE_LIST as a BOD) 1 Labelling for start date and number of days (as per diagram) 1 * For CAR_HIRE label: Accept: Hires / hired / Car data / hire data / hire record / one or more hires 5

Mark scheme, page 7

Page 7 Mark Scheme Syllabus Paper Cambridge International A Level – May/June 2016 9608 41 © Cambridge International Examinations 2016 Question Answer Marks 4 (a) (i) a03, h07, a23 accept in any order, must be lower case 1 (ii) The car must pass (both) brake test and tyres test 1 (b) retestAllowed(ThisCar) 1 If (testBrakes(ThisCar, pass) and testTyres(ThisCar, fail)) 1 or (testBrakes(ThisCar, fail) and testTyres(ThisCar, pass)) 1 (one mark per bold underlined all correct) accept another variable instead of ThisCar, but must be same throughout. 3 (c) (i) a07 [p03] must be [] must be lower case, but don’t penalise twice, so follow through from part(b) 2 (ii) [p05,m04] 1 (iii) [ ] 1 (d) [ ] 1 5 (a) (i) Mark Description Expected result (Grade) Normal FAIL/PASS/MERIT/DISTINCTION Abnormal Error Extreme/Boundary FAIL/PASS/MERIT/DISTINCTION 3 × (mark + matching grade) for abnormal data accept negative values, non-integer values, Expected Result: Error 0 and marks above 100 are still acceptable values Do not accept FAIL in expected result column for Abnormal data 3 (ii) (The programmer is) concerned only with the input (i.e. the mark) to the function and monitoring the expected output (i.e. the grade) // can compare expected result and actual result 1 (b) Exception: 1. situation causing a crash / run-time error / fatal error 1 Exception handling: 2. code which is called when a run-time error occurs 1 3. … to avoid the program terminating/crashing 1 3

Mark scheme, page 8

Page 8 Mark Scheme Syllabus Paper Cambridge International A Level – May/June 2016 9608 41 © Cambridge International Examinations 2016 Question Answer Marks (c) 1 Open a non-existent file 2 Directory path does not exist 3 Attempt to read past the end of the file // attempt to read an empty file 4 Array subscript is out of range 5 Non-integer value / corrupt data read 6 File already open in a different mode // wrong file permissions Max 3 (d) (i) 09 // 9 1 (ii) 1 Line 11 catches exceptions (only) between lines 05 and 10 1 2 Line 11 stops the program from crashing 1 3 Different exception types recognised 1 4 Each exception type has an appropriate message output 1 5 The program language has an (object) type EXCEPTION 1 6 ThisException is the instance of EXCEPTION which has been raised 1 7 EXCEPTION objects have a ‘Message’ property // the message property for ThisException is “Arithmetic operation resulted in an overflow” 1 Max 3 6 (a) Max 3 marks if extra states/transitions added. 4

Mark scheme, page 9

Page 9 Mark Scheme Syllabus Paper Cambridge International A Level – May/June 2016 9608 41 © Cambridge International Examinations 2016 Question Answer Marks (b) (i) Mark as follows: 1 Declaration for array (character or string data type) 2 FOR loop for x going from 1 to 8, generating column index used in array 3 FOR loop for y going from 1–2, 3–6, 7–8 (Accept all squares being set to 'E' and then overwritten with 'B', 'W' respectively) 4 Setting squares to 'B', 'E', 'W' (must be in quotes, accept single or double) 4 (ii) Mark as follows: 1 Procedure heading and declaration of 2 local variables 1 2 Establishing the stopper colour – opposite to the mover 1 3 Test for piece in column 1 (x>1) // column 8 (x<8) 1 4 Test for ‘E’ 1 5 Correct method for moving left // for moving right 1 6 until edge of board reached 1 7 until other colour (stopper colour) encountered 1 8 until own colour encountered (PieceColour) 1 9 Correct output for cell indexes 1 (accept for moving in 1 direction only) 10 including the ‘REMOVE’ message 1 Note: must use given parameter identifiers: PieceColour, xCurrent, yCurrent Max 5 (c) (i) Classes could be designed for : • the board • a piece Containment (Board contains Pieces) The pieces are instances/objects (of the Piece class) Max 2

Mark scheme, page 10

Page 10 Mark Scheme Syllabus Paper Cambridge International A Level – May/June 2016 9608 41 © Cambridge International Examinations 2016 Question Answer Marks (ii) Accept any reasonable answer, for example: BOARD class: Properties: • Number of squares / size / dimensions • Current state of all squares Methods: – • Set the starting board • Capture the finishing state of the board • Display the state of the board after each move PIECE class: Properties: • Starting x position • Starting y position • Current x position • current y position • Colour • State / Removed / Active Methods: • Move piece • Remove piece Mark as follows: two correct responses are worth 1 mark Accept other classes: Game, Player Max 2

Mark scheme, page 11

Page 11 Mark Scheme Syllabus Paper Cambridge International A Level – May/June 2016 9608 41 © Cambridge International Examinations 2016 Programming code 6 (b) (i) VB.NET Dim Board(8, 8) As Char Dim Row, Column As Integer For Row = 1 To 2 For Column = 1 To 8 Board(Row, Column) = "B" Next Next For Row = 3 To 6 For Column = 1 To 8 Board(Row, Column) = "E" Next Next For Row = 7 To 8 For Column = 1 To 8 Board(Row, Column) = "W" Next Next PASCAL var Row, Column : integer; Board : array[1..8, 1..8] of char; begin for Row := 1 to 2 do for Column := 1 to 8 do Board[Row, Column] := 'B'; for Row := 3 to 6 do for Column := 1 to 8 do Board[Row, Column] := 'E'; for Row := 7 to 8 do for Column := 1 to 8 do Board[Row, Column] := 'W'; end.

Mark scheme, page 12

Page 12 Mark Scheme Syllabus Paper Cambridge International A Level – May/June 2016 9608 41 © Cambridge International Examinations 2016 PYTHON Board = [["" for j in range(9)] for i in range(9)] for Row in range(1, 3) : for Column in range(1, 9) : Board[Row][Column] = "B" for Row in range(3, 7) : for Column in range(1, 9) : Board[Row][Column] = "E" for Row in range(7, 9) : for Column in range(1, 9) : Board[Row][Column] = "W" Alternative declarations of Board array : Board = [[""] * 9 for i in range(9)] Board = [[]] for i in range(9) : for j in range(9) : Board.append("") Instead of initialising with empty string, could initialise with ‘E’. this would then only require ‘B’ and ‘W’ loops later. For example: Board = [["E"] * 9 for i in range(9)] // Board =[["E"]*9]*9 for Row in range(1, 3) : for Column in range(1, 9) : Board[Row][Column] = "B" for Row in range(7, 9) : for Column in range(1, 9) : Board[Row][Column] = "W" Board =[] for i in range(9): Board.append(["E"]*9)

Mark scheme, page 13

Page 13 Mark Scheme Syllabus Paper Cambridge International A Level – May/June 2016 9608 41 © Cambridge International Examinations 2016 6 (b) (ii) VB.NET Sub ValidMoves(ByVal PieceColour As Char, ByVal xCurrent As Integer, ByVal yCurrent As Integer) Dim i As Integer Dim StopperColour As Char Dim NoFurther As Boolean If PieceColour = "B" Then StopperColour = "W" Else StopperColour = "B" End If Console.WriteLine("Possible moves are : ") If xCurrent <> 1 Then Console.WriteLine("Moving LEFT . . .") i = xCurrent – 1 NoFurther = False do if Board(i, yCurrent) = "E" Then Console.WriteLine(i & " " & yCurrent) End If if Board(i, yCurrent) = StopperColour Then Console.WriteLine(i & " " & yCurrent & " REMOVE PIECE") NoFurther = True End If i = i – 1 Loop Until i = 0 Or NoFurther = True End If if xCurrent <> 8 Then Console.WriteLine("Moving RIGHT . . .") i = xCurrent + 1 NoFurther = False do if Board(i, yCurrent) = "E" : Console.WriteLine(i & " " & yCurrent) End If if Board(i, yCurrent) = StopperColour Then Console.WriteLine(i & " " & yCurrent & " REMOVE PIECE") NoFurther = True End If i = i + 1 Loop Until i = 9 Or NoFurther = True End If End Sub

Mark scheme, page 14

Page 14 Mark Scheme Syllabus Paper Cambridge International A Level – May/June 2016 9608 41 © Cambridge International Examinations 2016 PASCAL procedure ValidMoves(PieceColour : char; xCurrent, yCurrent : integer); var StopperColour : char; i : integer; NoFurther : boolean; begin if (PieceColour = 'B') then StopperColour := 'W' else StopperColour := 'B'; writeln('Possible moves are : '); if (xCurrent <> 1) then begin writeln('Moving LEFT . . . '); i := xCurrent – 1; NoFurther := false; repeat if (Board[i, yCurrent] = 'E') then writeln(intToStr(i) + ' ' + intToStr(yCurrent)); if (Board[i, yCurrent] = StopperColour) then begin writeln(intToStr(i) + ' ' + intToStr(yCurrent) + ' REMOVE PIECE'); NoFurther := true; end; i := i – 1; until ((i = 0) or (NoFurther = true)); end; if (xCurrent <> 8) then begin writeln('Moving RIGHT . . . '); i := xCurrent + 1; NoFurther := false; repeat if (Board[i, yCurrent] = 'E') then writeln(intToStr(i) + ' ' + intToStr(yCurrent)); if (Board[i, yCurrent] = StopperColour) then begin writeln(intToStr(i) + ' ' + intToStr(yCurrent) + ' REMOVE PIECE'); NoFurther := true; end; i := i + 1; until ((i = 9) or (NoFurther = true)); end; end;

Mark scheme, page 15

Page 15 Mark Scheme Syllabus Paper Cambridge International A Level – May/June 2016 9608 41 © Cambridge International Examinations 2016 PYTHON def ValidMoves(PieceColour, xCurrent, yCurrent) : if PieceColour == "B" : StopperColour = "W" else : StopperColour = "B" print("Possible moves are : ") if xCurrent != 1 : print("Moving LEFT . . .") i = xCurrent – 1 NoFurther = False while i > 0 and NoFurther == False : if Board[i][yCurrent] == "E" : print(str(i) + " " + str(yCurrent)) if Board[i][yCurrent] == StopperColour : print(str(i) + " " + str(yCurrent) + " REMOVE PIECE") NoFurther = True i = i – 1 if xCurrent != 8 : print("Moving RIGHT . . .") i = xCurrent + 1 NoFurther = False while i < 9 and NoFurther == False : if Board[i][yCurrent] == "E" : print(str(i) + " " + str(yCurrent)) if Board[i][yCurrent] == StopperColour : print(str(i) + " " + str(yCurrent) + " REMOVE PIECE") NoFurther = True i = i + 1

What you needed in this session

Cambridge’s own grade thresholds for 2016 May/June, Paper 4 · Variant 1. A higher threshold means an easier paper — the bar moves with how the cohort did.

A56/75
B48/75
C39/75
D30/75
E22/75