Cambridge A Level Computer Science 9608 — 2018 Oct/Nov Paper 2 · Variant 3

9608/23/O/N/18 · 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 paper16 pages

Cambridge A Level Computer Science 9608 2018 Oct/Nov Paper 2 · Variant 3 question paper, page 1 of 16
Page 1 of 16
Cambridge A Level Computer Science 9608 2018 Oct/Nov Paper 2 · Variant 3 question paper, page 2 of 16
Page 2 of 16
Cambridge A Level Computer Science 9608 2018 Oct/Nov Paper 2 · Variant 3 question paper, page 3 of 16
Page 3 of 16
Cambridge A Level Computer Science 9608 2018 Oct/Nov Paper 2 · Variant 3 question paper, page 4 of 16
Page 4 of 16
Cambridge A Level Computer Science 9608 2018 Oct/Nov Paper 2 · Variant 3 question paper, page 5 of 16
Page 5 of 16
Cambridge A Level Computer Science 9608 2018 Oct/Nov Paper 2 · Variant 3 question paper, page 6 of 16
Page 6 of 16
Cambridge A Level Computer Science 9608 2018 Oct/Nov Paper 2 · Variant 3 question paper, page 7 of 16
Page 7 of 16
Cambridge A Level Computer Science 9608 2018 Oct/Nov Paper 2 · Variant 3 question paper, page 8 of 16
Page 8 of 16
Cambridge A Level Computer Science 9608 2018 Oct/Nov Paper 2 · Variant 3 question paper, page 9 of 16
Page 9 of 16
Cambridge A Level Computer Science 9608 2018 Oct/Nov Paper 2 · Variant 3 question paper, page 10 of 16
Page 10 of 16
Cambridge A Level Computer Science 9608 2018 Oct/Nov Paper 2 · Variant 3 question paper, page 11 of 16
Page 11 of 16
Cambridge A Level Computer Science 9608 2018 Oct/Nov Paper 2 · Variant 3 question paper, page 12 of 16
Page 12 of 16
Cambridge A Level Computer Science 9608 2018 Oct/Nov Paper 2 · Variant 3 question paper, page 13 of 16
Page 13 of 16
Cambridge A Level Computer Science 9608 2018 Oct/Nov Paper 2 · Variant 3 question paper, page 14 of 16
Page 14 of 16
Cambridge A Level Computer Science 9608 2018 Oct/Nov Paper 2 · Variant 3 question paper, page 15 of 16
Page 15 of 16
Cambridge A Level Computer Science 9608 2018 Oct/Nov Paper 2 · Variant 3 question paper, page 16 of 16
Page 16 of 16

Mark scheme13 pages

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

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

Paper as text

Question paper, page 1

This document consists of 16 printed pages. DC (NH/CT) 151783/3 © UCLES 2018 [Turn over * 4 4 2 0 5 0 2 9 9 4 * COMPUTER SCIENCE 9608/23 Paper 2 Fundamental Problem-solving and Programming Skills October/November 2018 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 Subsidiary and Advanced Level

Question paper, page 2

2 9608/23/O/N/18 © UCLES 2018 Question 1 begins on the next 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.

Question paper, page 3

3 9608/23/O/N/18 © UCLES 2018 [Turn over 1 (a) The following table contains statements written in pseudocode. Show the type of programming construct each statement represents. Put a tick (3) in the appropriate column for each statement. Statement Assignment Selection Repetition (Iteration) CASE OF TempSensor1 ELSE REPEAT ENDFOR DayNumber DayNumber + 1 Error TRUE [6] (b) (i) The following table contains statements written in pseudocode. Give the most appropriate data type for the variable used in each statement. Statement Data type Revision 500 FuelType 'P' MinValue -6.3 ServiceDue FALSE ModelRef "W212DEC15" [5] (ii) The following table contains statements written in pseudocode. Complete the table by evaluating each expression using the values from part (b)(i). If any expression is invalid, write “ERROR” in the Evaluates to column. For the built-in functions list, refer to the Appendix on page 16. Expression Evaluates to "Month: " & MID(ModelRef, 5, 3) INT(MinValue * 2) ASC(Revision) Revision > 500 ServiceDue = TRUE OR FuelType = 'P' [5]

Question paper, page 4

4 9608/23/O/N/18 © UCLES 2018 2 Shop customers have a discount card with a unique card number. Customers collect points when they buy items. At the end of each year, customers are given bonus (extra) points related to the total amount they have spent during the year, and the number of points they have on their card. The function CalcBonus() takes the card number as a parameter. It returns the bonus points for the customer. A flowchart for the function is shown. The function uses the following variables and functions. Identifier Data type Description CardNum STRING A numeric string representing the unique card number Points INTEGER The number of points collected Spend REAL The total amount that customer has spent during the year Bonus INTEGER The number of bonus points GetPoints() FUNCTION Takes the card number as a parameter and returns the number of points already collected GetSpend() FUNCTION Takes the card number as a parameter and returns the total amount that customer has spent during the year START Points GetPoints(CardNum) Spend GetSpend(CardNum) Is Points > 2000 ? Is Spend > 1000 ? Bonus 10 Bonus 50 Bonus 100 RETURN Bonus END YES YES NO NO

Question paper, page 5

5 9608/23/O/N/18 © UCLES 2018 [Turn over (a) (i) Write pseudocode for the CalcBonus() function. Your solution should follow the flowchart for the function as closely as possible. … … … … … … … … … … … … … … … … … … … … … … …[5]

Question paper, page 6

6 9608/23/O/N/18 © UCLES 2018 (ii) The function GetCardNumber() prompts the user to input a card number until the number input is valid. A valid card number has 16 characters. Each character is a numeric character ('0' to '9'). Write pseudocode to complete the GetCardNumber() function. You should refer to the function IS_NUM() in the Appendix on page 16. FUNCTION GetCardNumber() RETURNS STRING … … … … … … … … … … … … … … … … … … … … … … … ENDFUNCTION [6]

Question paper, page 7

7 9608/23/O/N/18 © UCLES 2018 [Turn over (b) The function CalcBonus() is written in a high-level language. (i) The function is tested using black-box testing and does not contain any syntax errors. Name and describe one other type of error that black-box testing could find. Name … Description … … … [2] (ii) The function CalcBonus() is tested using white-box testing. State two different pairs of values for Spend and Points that can be used to test different paths through the function. Justify your choices. Spend … Points … Justification … … … Spend … Points … Justification … … … [4] (c) Name two types of program maintenance and state the reason why each is needed. Name … Reason … … … Name … Reason … … … [4]

Question paper, page 8

8 9608/23/O/N/18 © UCLES 2018 3 An array contains 100 integer values. An algorithm will find the maximum and minimum values stored in the array. (a) A programmer has started to write this program using a conditional loop. Name a more appropriate loop structure for this task and justify your choice. Name … Justification … … … [2] (b) Outline the steps the program will need to follow to implement the algorithm. Do not write pseudocode or program code. … … … … … … … …[3]

Question paper, page 9

9 9608/23/O/N/18 © UCLES 2018 [Turn over Question 4 begins on the next page.

Question paper, page 10

10 9608/23/O/N/18 © UCLES 2018 4 Part of a program written in pseudocode is shown. 010 DECLARE ThisArray : ARRAY [1:100, 1:10] OF STRING 011 DECLARE LastElement : INTEGER … 100 FUNCTION Update(NewData : STRING) RETURNS INTEGER 101 DECLARE ArrayIndex : INTEGER 102 DECLARE Found : BOOLEAN 103 104 ArrayIndex 1 105 Found FALSE 106 107 WHILE ArrayIndex <= LastElement AND Found = FALSE 108 IF ThisArray[ArrayIndex, 1] > NewData 109 THEN 110 Found TRUE 111 ELSE 112 ArrayIndex ArrayIndex + 1 113 ENDIF 114 ENDWHILE 115 116 IF Found = TRUE 117 THEN 118 CALL Insert(ArrayIndex, NewData) 119 ELSE 120 ArrayIndex 0 121 ENDIF 122 123 RETURN ArrayIndex 124 ENDFUNCTION (a) (i) Examine the pseudocode and complete the following table. Answer The name of a global identifier The name of a user-defined procedure The scope of ArrayIndex The number of dimensions of ThisArray The scope of NewData [5] (ii) Describe in detail, the purpose of lines 107 to 114 in the Update() function. Do not use pseudocode in your answer. … … … … … …[4]

Question paper, page 11

11 9608/23/O/N/18 © UCLES 2018 [Turn over (b) Line 118 of the function Update() calls the subroutine Insert(). A designer decides to convert Insert() from a procedure to a function. Insert() returns TRUE or FALSE. A programmer must amend the function Update() as follows: • If Insert() returns FALSE then the function Update() returns -1 • If Insert() returns TRUE then the function Update() returns the value as before. Write program code to implement the amended Update() function. 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 … Program code … … … … … … … … … … … … … … … … … … … … … …[8]

Question paper, page 12

12 9608/23/O/N/18 © UCLES 2018 (c) The function Update() is an example of a module within a program. Describe the mechanism that supports the transfer of values between modules. … … … … …[2] (d) (i) CharArray is a 1D array of type CHAR. It contains 200 elements. Write program code to change all the numeric characters ('0' to '9') in CharArray to '*'. Programming language … Program code … … … … … … … …[3] (ii) A programmer decides to declare LastElement as a constant instead of a variable. Write a statement in pseudocode to declare LastElement as the value 200. …[1]

Question paper, page 13

13 9608/23/O/N/18 © UCLES 2018 [Turn over Question 5 begins on the next page.

Question paper, page 14

14 9608/23/O/N/18 © UCLES 2018 5 The function ReadFileLine() returns a specific line from a text file. The function takes two parameters: Identifier Data type Description FileName STRING The name of the text file FileLine INTEGER The line number that is required The following pseudocode gives an example of the use of the function. FileData ReadFileLine(FileName, FileLine) The function ReadFileLine() will: • open the file, FileName • read each line from the file until line FileLine is found or the end of the file is reached • if the line exists, return the string from this line; otherwise return the string "****"

Question paper, page 15

15 9608/23/O/N/18 © UCLES 2018 [Turn over Write pseudocode for the ReadFileLine() function. … … … … … … … … … … … … … … … … … … … … … … … … … … … … …[10]

Question paper, page 16

16 9608/23/O/N/18 © UCLES 2018 Appendix Built-in functions (pseudocode) Each function returns an error if the function call is not properly formed. MID(ThisString : STRING, x : INTEGER, y : INTEGER) RETURNS STRING returns a string of length y starting at position x from ThisString Example: MID("ABCDEFGH", 2, 3) returns string "BCD" LEFT(ThisString : STRING, x : INTEGER) RETURNS STRING returns leftmost x characters from ThisString Example: LEFT("ABCDEFGH", 3) returns string "ABC" RIGHT(ThisString: STRING, x : INTEGER) RETURNS STRING returns rightmost x characters from ThisString Example: RIGHT("ABCDEFGH", 3) returns string "FGH" LENGTH(ThisString : STRING) RETURNS INTEGER returns the integer value representing the length of ThisString Example: LENGTH("Happy Days") returns 10 INT(x : REAL) RETURNS INTEGER returns the integer part of x Example: INT(27.5415) returns 27 ASC(ThisChar : CHAR) RETURNS INTEGER returns the ASCII value of ThisChar Example: ASC('A') returns 65 IS_NUM(ThisString : STRING) RETURNS BOOLEAN returns the value TRUE if ThisString contains only numeric characters ('0' to '9'). Example: IS_NUM("1234X67") returns FALSE Operators (pseudocode) Operator Description & Concatenates (joins) two strings Example: "Summer" & " " & "Pudding" produces "Summer Pudding" AND Performs a logical AND on two Boolean values Example: TRUE AND FALSE produces FALSE OR Performs a logical OR on two Boolean values Example: TRUE OR FALSE produces TRUE

Mark scheme, page 1

This document consists of 13 printed pages. © UCLES 2018 [Turn over Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level COMPUTER SCIENCE 9608/23 Paper 2 Written Paper October/November 2018 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 International will not enter into discussions about these mark schemes. Cambridge International is publishing the mark schemes for the October/November 2018 series for most Cambridge IGCSE™, Cambridge International A and AS Level components and some Cambridge O Level components.

Mark scheme, page 2

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2018 © UCLES 2018 Page 2 of 13 Generic Marking Principles These general marking principles must be applied by all examiners when marking candidate answers. They should be applied alongside the specific content of the mark scheme or generic level descriptors for a question. Each question paper and mark scheme will also comply with these marking principles. GENERIC MARKING PRINCIPLE 1: Marks must be awarded in line with: • the specific content of the mark scheme or the generic level descriptors for the question • the specific skills defined in the mark scheme or in the generic level descriptors for the question • the standard of response required by a candidate as exemplified by the standardisation scripts. GENERIC MARKING PRINCIPLE 2: Marks awarded are always whole marks (not half marks, or other fractions). GENERIC MARKING PRINCIPLE 3: Marks must be awarded positively: • marks are awarded for correct/valid answers, as defined in the mark scheme. However, credit is given for valid answers which go beyond the scope of the syllabus and mark scheme, referring to your Team Leader as appropriate • marks are awarded when candidates clearly demonstrate what they know and can do • marks are not deducted for errors • marks are not deducted for omissions • answers should only be judged on the quality of spelling, punctuation and grammar when these features are specifically assessed by the question as indicated by the mark scheme. The meaning, however, should be unambiguous. GENERIC MARKING PRINCIPLE 4: Rules must be applied consistently e.g. in situations where candidates have not followed instructions or in the application of generic level descriptors. GENERIC MARKING PRINCIPLE 5: Marks should be awarded using the full range of marks defined in the mark scheme for the question (however; the use of the full mark range may be limited according to the quality of the candidate responses seen). GENERIC MARKING PRINCIPLE 6: Marks awarded are based solely on the requirements as defined in the mark scheme. Marks should not be awarded with grade thresholds or grade descriptors in mind.

Mark scheme, page 3

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2018 © UCLES 2018 Page 3 of 13 Question Answer Marks 1(a)(i) Statement Assignment Selection Iteration CASE OF TempSensor1 3 ELSE 3 REPEAT 3 ENDFOR 3 DayNumber ← DayNumber + 1 3 Error ← TRUE 3 One mark per row 6 1(b)(i) Statement Data type Revision ← 500 INTEGER FuelType ← 'P' CHAR MinValue ← -6.3 REAL ServiceDue ← FALSE BOOLEAN ModelRef ← "W212DEC15" STRING One mark per row 5 1(b)(ii) Expression Evaluates to "Month: " & MID(ModelRef, 5, 3) "Month: DEC" INT(MinValue * 2) –12 ASC(Revision) ERROR Revision > 500 FALSE ServiceDue = TRUE OR FuelType = 'P' TRUE One mark per row 5

Mark scheme, page 4

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2018 © UCLES 2018 Page 4 of 13 Question Answer Marks 2(a)(i) FUNCTION CalcBonus(CardNum: STRING) RETURNS INTEGER DECLARE Points : INTEGER DECLARE Bonus : INTEGER DECLARE Spend : REAL Points ← GetPoints(CardNum) Spend ← GetSpend(CardNum) IF Points > 2000 THEN Bonus ← 100 ELSE IF Spend > 1000 THEN Bonus ← 50 ELSE Bonus ← 10 ENDIF ENDIF RETURN Bonus ENDFUNCTION 1 mark for each of the following up to max 5 marks: 1 Function heading (inc parameters) and ending 2 Declaring local variables and two function calls as above 3 IF…THEN…ELSE…ENDIF with Points > 2000 4 (Nested) IF«THEN…ELSE with Spend > 1000 5 « assignment of Bonus to 10, 50 100 6 Return parameter 5

Mark scheme, page 5

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2018 © UCLES 2018 Page 5 of 13 Question Answer Marks 2(a)(ii) The pseudocode shown here is only an example. The use of an explicit flag and IF structure are not essential provided the functionality is provided. FUNCTION GetCardNumber() RETURNS STRING DECLARE Valid : BOOLEAN DECLARE CardNum : STRING Valid ← FALSE REPEAT OUTPUT "Enter card number" INPUT CardNum IF LENGTH(CardNum) = 16 AND IS_NUM(CardNum) = TRUE THEN Valid ← TRUE ENDIF UNTIL Valid RETURN CardNum ENDFUNCTION 1 mark for each of the following: 1 Declaring local variable to store user input 2 Conditional Loop 3 Prompt and input of CardNum 4 Length check 5 Checking IS_NUM(CardNum) is TRUE 6 Return a value 6 2(b)(i) Name: Logic (error) Description: Where the program does not behave as expected / Does not give expected result / An error in the logic of the algorithm OR Name: Run-time // execution (error) Description: The program performs an illegal operation One mark for name + one mark for corresponding description 2 2(b)(ii) Values: any Spend value and Points > 2000 Justification: Bonus should be 100 Values: Spend > 1000 and Points <= 2000 Justification: Bonus should be 50 Values: Spend <= 1000 and Points <= 2000 Justification: Bonus should be 10 2 marks for values 2 marks for relevant and appropriate reasons 4

Mark scheme, page 6

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2018 © UCLES 2018 Page 6 of 13 Question Answer Marks 2(c) Name: Corrective Reason: Amend the algorithm to ‘eliminate errors’ Name: Adaptive Reason: In response to specification change arising from changes to business rules or environment (regulatory) Name: Perfective Reason: To make improvements to the program One mark for each name plus one mark for corresponding reason up to max 4 marks 4 Question Answer Marks 3(a) Name: count controlled / FOR ... NEXT loop Justification: Known / fixed number of iterations // all elements of the array need to be checked 1 mark for name 1 mark for justification 2 3(b) Steps: • Declare (and initialise values to first array element) for min and max as integers • A loop / iteration / repetition to check every element • Compare each array element with max variable and min variable • Update max variable if bigger and min variable if smaller 1 mark per bullet point Alternative steps: • Apply a sort routine to the values in the array • Swapping consecutive elements (as necessary) // until no more swaps • Min will be the first / last element and max will be the last / first element 1 mark per bullet point Max 3 marks 3

Mark scheme, page 7

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2018 © UCLES 2018 Page 7 of 13 Question Answer Marks 4(a)(i) The name of a global identifier LastElement // ThisArray The name of a user-defined procedure Insert The scope of ArrayIndex Local The number of dimensions of ThisArray 2 The scope of NewData Local 5 4(a)(ii) Example mark points: • Conditional loop through array ThisArray one element at a time until found • Compare the element from row / column 1 of the array with NewData • If the current element is greater than NewData set Found to TRUE (to exit the loop) • If the current element is not greater than NewData increment ArrayIndex 4

Mark scheme, page 8

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2018 © UCLES 2018 Page 8 of 13 Question Answer Marks 4(b) ‘Pseudocode’ solution included here for development and clarification of mark scheme. Programming language solutions appear at the end of this mark scheme. FUNCTION Update(NewData: STRING) RETURNS INTEGER DECLARE ArrayIndex : INTEGER DECLARE Found : BOOLEAN DECLARE Validate : BOOLEAN ArrayIndex ← 1 Found ← FALSE WHILE ArrayIndex <= LastElement AND Found = FALSE IF ThisArray[ArrayIndex, 1] > NewData THEN Found ← TRUE ELSE ArrayIndex ← ArrayIndex + 1 ENDIF ENDWHILE IF Found = TRUE THEN Validate ← Insert(ArrayIndex, NewData) IF Validate = FALSE THEN ArrayIndex ← -1 ENDIF ELSE ArrayIndex ← 0 ENDIF RETURN ArrayIndex ENDFUNCTION 1 mark for each of the following: 1 Function heading and ending including parameters 2 Local variable declarations and Initialisation of ArrayIndex and Found 3 WHILE loop 4 First IF–THEN–ELSE–ENDIF clause 5 Second IF clause including function call to Insert() 6 Check Return value 7 Set / return –1 IF (Validate) FALSE 8 Return parameter value (–1 or 0 // ArrayIndex) 8

Mark scheme, page 9

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2018 © UCLES 2018 Page 9 of 13 Question Answer Marks 4(c) Description to include: • mechanism involves using parameters .. to pass values from one procedure to another • parameters may be ‘by reference’ or ‘by value’ 2 4(d)(i) Pseudocode solution included here for development and clarification of mark scheme. Programming language solutions appear at the end of this mark scheme. DECLARE i : INTEGER FOR i ← 1 to 200 IF CharArray[i] >= '0' AND CharArray[i]<= '9' THEN CharArray[i] ← '*' ENDIF ENDFOR 1 mark for each of the following: • looping through 200 elements • selection statement • assignment of ‘*’ 3 4(d)(ii) CONSTANT LastElement = 200 1

Mark scheme, page 10

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2018 © UCLES 2018 Page 10 of 13 Question Answer Marks 5 FUNCTION ReadFileLine(FileName: STRING, FileLine: INTEGER) RETURNS STRING DECLARE FileData : STRING DECLARE LineNumber : INTEGER OPENFILE FileName FOR READ LineNumber ← 0 // no line read yet WHILE (NOT EOF(FileName)) AND FileLine <> LineNumber READFILE FileName, FileData LineNumber ← LineNumber + 1 ENDWHILE IF FileLine <> LineNumber THEN FileData ← "****" ENDIF CLOSEFILE FileName RETURN FileData ENDFUNCTION 1 mark for each of the following: 1 Function heading including parameters. 2 Declare local variables FileData and LineNumber 3 Open FileName in READ mode 4 WHILE loop 5 Call to READFILE() (in a loop) 6 Incrementing LineNumber (in a loop) 7 IF FileLine <> LineNumber (after a loop) 8 ...Set FileData to "****" 9 Close FileName 10 Return FileData 10 *** End of Mark Scheme – program code solutions follow ***

Mark scheme, page 11

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2018 © UCLES 2018 Page 11 of 13 Program Code Example Solutions Q4(b): Visual Basic FUNCTION Update(ByVal NewData AS STRING) AS INTEGER DIM ArrayIndex AS INTEGER DIM Found AS BOOLEAN DIM Validate AS BOOLEAN ArrayIndex = 1 Found = FALSE WHILE ArrayIndex <= LastElement AND Found = FALSE IF ThisArray[ArrayIndex, 1] > NewData THEN Found = TRUE ELSE ArrayIndex = ArrayIndex + 1 ENDIF ENDWHILE **IF Found = TRUE THEN Validate = Insert(ArrayIndex, NewData) IF Validate = FALSE THEN ArrayIndex = -1 ENDIF ELSE ArrayIndex = 0 ENDIF RETURN ArrayIndex // Update = ArrayIndex ENDFUNCTION ** Alternative IF Found = FALSE THEN ArrayIndex = 0 ELSE Validate = Insert(ArrayIndex, NewData) IF Validate = FALSE THEN ArrayIndex = -1 ENDIF ENDIF RETURN ArrayIndex Q4(b): Pascal function Update(NewData: string): integer;

Mark scheme, page 12

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2018 © UCLES 2018 Page 12 of 13 var ArrayIndex : integer; var Found : boolean; var Validate : boolean; begin ArrayIndex := 1; Found := FALSE; while ArrayIndex <= LastElement AND Found = FALSE do begin if ThisArray[ArrayIndex, 1] > NewData then found := True else ArrayIndex := ArrayIndex + 1; end; if Found = TRUE then begin Validate := Insert(ArrayIndex, NewData); if Validate = FALSE then ArrayIndex := -1; end else begin ArrayIndex := 0; end; Update := ArrayIndex; end; Q4(b): Python def Update(NewData): # ArrayIndex AS INTEGER # Found AS BOOLEAN # Validate AS BOOLEAN ArrayIndex = 1 Found = FALSE LastElement = 20 while ArrayIndex <= LastElement AND Found == FALSE: if ThisArray[ArrayIndex][1] > NewData: Found = TRUE else: ArrayIndex = ArrayIndex + 1 if Found == TRUE: Validate = Insert(ArrayIndex, NewData) if Validate == FALSE: ArrayIndex = -1 else: ArrayIndex = 0 return ArrayIndex

Mark scheme, page 13

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2018 © UCLES 2018 Page 13 of 13 Q4(d)(i): Visual Basic Dim i AS Integer For i = 1 to 200 If CharArray(i) >= ‘0’ AND CharArray(i) <= ‘9’ then CharArray(i) = ‘*’ Endif Next i Q4(d)(i): Pascal var i : integer; for i := 1 to 200 do begin If CharArray(i) >= ‘0’ AND CharArray(i) <= ‘9’ then CharArray(i):= ‘*’; end; Q4(d)(i): Python #i as string for i in CharArray: if CharArray.isdigit: i = '*' ** Alternative # i as integer for i in range(200): if CharArray[i] >= '0' and CharArray[i] <= '9': CharArray[i] = '*'

What you needed in this session

Cambridge’s own grade thresholds for 2018 Oct/Nov, Paper 2 · Variant 3. A higher threshold means an easier paper — the bar moves with how the cohort did.

A52/75
B45/75
C36/75
D28/75
E20/75