Cambridge A Level Computer Science 9608 — 2019 Oct/Nov Paper 2 · Variant 1
9608/21/O/N/19 · 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 paper20 pages




















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















Paper as text
Question paper, page 1
This document consists of 17 printed pages and 3 blank pages. DC (ST) 171120/3 © UCLES 2019 [Turn over * 9 7 4 4 6 8 1 1 6 1 * COMPUTER SCIENCE 9608/21 Paper 2 Fundamental Problem-solving and Programming Skills October/November 2019 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 Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level
Question paper, page 2
2 9608/21/O/N/19 © UCLES 2019 1 Study the following pseudocode. FUNCTION Search() RETURNS INTEGER DECLARE N, C : INTEGER DECLARE V, L : REAL V GetLevel() L V * 1.34 C 0 FOR N 1 TO 10 V GetLevel() IF V > L THEN C C + 1 ENDIF ENDFOR OUTPUT "Process complete" RETURN C ENDFUNCTION (a) (i) This pseudocode lacks features that would make it easier to read and understand. State three such features. Feature 1 … Feature 2 … Feature 3 … [3]
Question paper, page 3
3 9608/21/O/N/19 © UCLES 2019 [Turn over (ii) Draw a program flowchart to represent the algorithm implemented in the pseudocode. Variable declarations are not required in program flowcharts. [5]
Question paper, page 4
4 9608/21/O/N/19 © UCLES 2019 (b) (i) Programming languages support different data types. Complete the table by giving a suitable data type for each example value. Example value Data type "NOT TRUE" − 4.5 NOT FALSE 132 [4] (ii) Evaluate each expression in the following table. If an expression is invalid then write ‘ERROR’. Refer to the Appendix on page 16–17 for the list of built-in functions and operators. Expression Evaluates to LEFT("Start", 3) & RIGHT("Apple", 3) MID("sample", 3, 5) NUM_TO_STRING(12.3 * 2) INT(STRING_TO_NUM("53.4")) + 7 [4]
Question paper, page 5
5 9608/21/O/N/19 © UCLES 2019 [Turn over 2 (a) A structure chart is often used in modular program design. One feature shown is the sequence of module execution. State four other features that may be shown. Feature 1 … … Feature 2 … … Feature 3 … … Feature 4 … … [4] (b) Identify and describe one feature of an Integrated Development Environment (IDE) that can help with program presentation. Feature … Description … … [2] (c) By value is one method of passing a parameter to a subroutine. Identify and describe the other method. Method … Description … … … [2] (d) Explain the term adaptive maintenance. … … … … [2]
Question paper, page 6
6 9608/21/O/N/19 © UCLES 2019 3 The following is a function design in pseudocode. Line numbers are given for reference only. 10 FUNCTION Check(InString : STRING) RETURNS BOOLEAN 11 12 DECLARE NumDots : INTEGER 13 DECLARE Index : INTEGER 14 DECLARE NumOthers : INTEGER 15 16 NumDots 0 17 NumOthers 0 18 Index 1 19 20 WHILE NumDots < 3 AND Index <= LENGTH(InString) 21 22 IF MID(InString, Index, 1) = '.' 23 THEN 24 NumDots NumDots + 1 25 ELSE 26 NumOthers NumOthers + 1 27 ENDIF 28 Index Index + 1 29 30 ENDWHILE 31 32 IF NumDots = NumOthers 33 THEN 34 RETURN TRUE 35 ELSE 36 RETURN FALSE 37 ENDIF 38 39 ENDFUNCTION
Question paper, page 7
7 9608/21/O/N/19 © UCLES 2019 [Turn over Study the pseudocode. Identify the relevant features in the following table. Refer to the Appendix on pages 16–17 for the list of built-in functions and operators. Feature Answer The number of the line containing a variable being incremented The range of line numbers containing a pre-condition loop The number of initialisation statements The number of the line containing a logical operator The range of line numbers containing a selection statement The name of a built-in function The name of a parameter [7]
Question paper, page 8
8 9608/21/O/N/19 © UCLES 2019 4 A student is developing a program to count how many times each character of the alphabet (A to Z) occurs in a given string. Upper case and lower case characters will be counted as the same. The string may contain non-alphabetic characters, which should be ignored. The program will: • check each character in the string to count how many times each alphabetic character occurs • store the count for each alphabetic character in a 1D array • output each count together with the corresponding character. (a) The student has written a structured English description of the algorithm: 1. START at the beginning of the string 2. SELECT a character from the string 3. CONVERT the character to upper case 4. CHECK whether the character is alphabetic and INCREMENT as required. 5. REPEAT from step 2 until last character has been checked 6. OUTPUT a suitable message giving the count of each alphabetic character Step 4 above is not described in sufficient detail. The student decides to apply a process to increase the level of detail given in step 4. State the name of the process and use this process to write step 4 in more detail. Use structured English for your answer. Process … Structured English … … … … … … [4]
Question paper, page 9
9 9608/21/O/N/19 © UCLES 2019 [Turn over (b) Write pseudocode to implement the program. You should note the following: • InString contains the string to be checked. It has been assigned a value. • The elements of the array Result have all been initialised to zero. • The ASCII value of letter ‘A’ is 65. You should assume the following lines of pseudocode have been written: DECLARE InString : STRING DECLARE Result : ARRAY [1:26] OF INTEGER Declare any further variables you use. Do not implement the code as a subroutine. Refer to the Appendix on pages 16–17 for the list of built-in functions and operators. … … … … … … … … … … … … … … … … … … [7]
Question paper, page 10
10 9608/21/O/N/19 © UCLES 2019 5 The following pseudocode checks whether a string is a valid password. FUNCTION CheckPassword(InString : STRING) RETURNS BOOLEAN DECLARE Index, Upper, Lower, Digit, Other : INTEGER DECLARE NextChar : CHAR Upper 0 Lower 0 Digit 0 Other 0 FOR Index 1 TO LENGTH(InString) NextChar MID(InString, Index, 1) IF NextChar >= 'A' AND NextChar <= 'Z' THEN Upper Upper + 1 ELSE IF NextChar >= 'a' AND NextChar <= 'z' THEN Lower Lower + 1 ELSE IF NextChar >= '0' AND NextChar <= '9' THEN Digit Digit + 1 ELSE Other Other + 1 ENDIF ENDIF ENDIF ENDFOR IF Upper > 1 AND Lower >= 5 AND (Digit - Other) > 0 THEN RETURN TRUE ELSE RETURN FALSE ENDIF ENDFUNCTION (a) Describe the validation rules that are implemented by this pseudocode. Refer only to the contents of the string and not to features of the pseudocode. … … … … … … [3]
Question paper, page 11
11 9608/21/O/N/19 © UCLES 2019 [Turn over (b) (i) Complete the trace table by dry running the function when it is called as follows: Result CheckPassword("Jim+Smith*99") Index NextChar Upper Lower Digit Other [5] (ii) State the value returned when the function is called using the expression shown. Justify your answer. Value … Justification … … … [2]
Question paper, page 12
12 9608/21/O/N/19 © UCLES 2019 6 Account information for users of a library is held in one of two text files; UserListAtoM.txt and UserListNtoZ.txt The format of the data held in the two files is identical. Each line of the file is stored as a string that contains an account number, name and telephone number separated by the asterisk character ('*') as follows: <Account Number>'*'<Name>'*'<Telephone Number> An example of one line from the file is: "GB1234*Kevin Mapunga*07789123456" The account number string may be six or nine characters in length and is unique for each person. It is made up of alphabetic and numeric characters only. An error has occurred and the same account number has been given to different users in the two files. There is no duplication of account numbers within each individual file. A program is to be written to search the two files and to identify duplicate entries. The account number of any duplicate found is to be written to an array, Duplicates, which is a 1D array of 100 elements of data type STRING. The program is to be implemented as several modules. The outline description of three of these is as follows: Module Outline description ClearArray() • Initialise the global array Duplicates. Set all elements to the empty string. FindDuplicates() • Read each line from the file UserListAtoM.txt • Check whether the account number appears in file UserListNtoZ.txt using SearchFileNtoZ() • If the account number does appear then add the account number to the array. • Output an error message and exit the module if there are more duplicates than can be written to the array. SearchFileNtoZ() • Search for a given account number in file UserListNtoZ.txt • If found, return TRUE, otherwise return FALSE (a) State one reason for storing data in a file rather than in an array. … … [1]
Question paper, page 13
13 9608/21/O/N/19 © UCLES 2019 [Turn over (b) Write program code for the module SearchFileNtoZ(). 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 … … … … … … … … … … … … … … … … … … … … … … … … [7]
Question paper, page 14
14 9608/21/O/N/19 © UCLES 2019 (c) Write pseudocode for the module FindDuplicates(). The module description is given in the table on page 12. … … … … … … … … … … … … … … … … … … … … … … … … … …
Question paper, page 15
15 9608/21/O/N/19 © UCLES 2019 [Turn over … … … … … … … [8] (d) ClearArray() is to be modified to make it general purpose. It will be used to initialise any 1D array of data type STRING to any value. It will now be called with three parameters as follows: 1. The array 2. The number of elements 3. The initialisation string You should assume that the lower bound is 1. (i) Write pseudocode for the modified ClearArray() procedure. … … … … … … … … [3] (ii) Write program code for a statement that calls the modified ClearArray() procedure to clear the array Duplicates to "Empty". Programming language … Program code … … [2]
Question paper, page 16
16 9608/21/O/N/19 © UCLES 2019 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 "BCD" LENGTH(ThisString : STRING) RETURNS INTEGER returns the integer value representing the length of ThisString Example: LENGTH("Happy Days") returns 10 LEFT(ThisString : STRING, x : INTEGER) RETURNS STRING returns leftmost x characters from ThisString Example: LEFT("ABCDEFGH", 3) returns "ABC" RIGHT(ThisString: STRING, x : INTEGER) RETURNS STRING returns rightmost x characters from ThisString Example: RIGHT("ABCDEFGH", 3) returns "FGH" INT(x : REAL) RETURNS INTEGER returns the integer part of x Example: INT(27.5415) returns 27 NUM_TO_STRING(x : REAL) RETURNS STRING returns a string representation of a numeric value. Note: This function will also work if x is of type INTEGER Example: NUM_TO_STRING(87.5) returns "87.5" STRING_TO_NUM(x : STRING) RETURNS REAL returns a numeric representation of a string. Note: This function will also work if x is of type CHAR Example: STRING_TO_NUM("23.45") returns 23.45 ASC(ThisChar : CHAR) RETURNS INTEGER returns the ASCII value of ThisChar Example: ASC('A') returns 65 CHR(x : INTEGER) RETURNS CHAR returns the character whose ASCII value is x Example: CHR(87) returns 'W'
Question paper, page 17
17 9608/21/O/N/19 © UCLES 2019 UCASE(ThisChar : CHAR) RETURNS CHAR returns the character value representing the upper case equivalent of ThisChar If ThisChar is not a lower case alphabetic character, it is returned unchanged. Example: UCASE('a') returns 'A' 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
Question paper, page 18
18 9608/21/O/N/19 © UCLES 2019 BLANK PAGE
Question paper, page 19
19 9608/21/O/N/19 © UCLES 2019 BLANK PAGE
Question paper, page 20
20 9608/21/O/N/19 © UCLES 2019 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 Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cambridgeinternational.org after the live examination series. Cambridge Assessment International Education is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of Cambridge Local Examinations Syndicate (UCLES), which itself is a department of the University of Cambridge. BLANK PAGE
Mark scheme, page 1
This document consists of 15 printed pages. © UCLES 2019 [Turn over Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level COMPUTER SCIENCE 9608/21 Paper 2 Written Paper October/November 2019 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 2019 series for most Cambridge IGCSE™, Cambridge International A and AS Level components and some Cambridge O Level components.
Mark scheme, page 2
9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2019 © UCLES 2019 Page 2 of 15 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/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2019 © UCLES 2019 Page 3 of 15 Question Answer Marks 1(a)(i) One mark for each feature: 1. meaningful / sensible identifier names // use of Camel case for identifier names // use of constants 2. blank lines / white space 3. comments 3
Mark scheme, page 4
9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2019 © UCLES 2019 Page 4 of 15 Question Answer Marks 1(a)(ii) 5 Mark as follows: • One mark for START and END • One mark per area outlined At least one decision box label (YES/NO) must be present
Mark scheme, page 5
9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2019 © UCLES 2019 Page 5 of 15 Question Answer Marks 1(b)(i) One mark per row Example value Data type "NOT TRUE" STRING − 4.5 REAL NOT FALSE BOOLEAN 132 INTEGER 4 1(b)(ii) One mark per row Expression Evaluates to LEFT("Start", 3) & RIGHT("Apple", 3) "Staple" MID("sample", 3, 5) ERROR NUM_TO_STRING(12.3 * 2) "24.6" INT(STRING_TO_NUM("53.4")) + 7 60 4
Mark scheme, page 6
9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2019 © UCLES 2019 Page 6 of 15 Question Answer Marks 2(a) One mark for each feature: 1. Module hierarchy 2. The parameters that are passed (between modules) // the module interface 3. Selection / Decisions (which modules are executed) 4. Iteration / Repetition 4 2(b) One mark for name and one mark for explanation. Example: • PrettyPrint // Colour coding • Colour coding of command words / key words • Expand and collapse code blocks • Allows programmer to focus on a section of code // allows quicker navigation of the code • Auto(matic) indentation • Allows the programmer to clearly see the different code sections / easier to see the code structure Accept suitable alternatives 2 2(c) One mark for identification, one mark for description: • By reference / ref • The address of / pointer to the parameter is passed to the subroutine // if the parameter value is changed in the subroutine this changes the original value 2 2(d) One mark per bullet point: • Changes made to // Updating // Editing a program / algorithm / data structure / software / system • ...as a result of changes to requirements / specification / legislation / available technology 2
Mark scheme, page 7
9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2019 © UCLES 2019 Page 7 of 15 Question Answer Marks 3 One mark per row: Answer The number of the line containing a variable being i t d 24 / 26 / 28 The range of line numbers containing a pre-condition loop 20 – 30 The number of initialisation statements 3 The number of the line containing a logical operator 20 The range of line numbers containing a selection statement 22 - 27 / 32 - 37 The name of a built-in function MID / LENGTH The name of a parameter InString / Index 7
Mark scheme, page 8
9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2019 © UCLES 2019 Page 8 of 15 Question Answer Marks 4(a) One mark for process name, max 3 for structured English. Process: • Stepwise Refinement / Top-down design Structured English: • Check that character is between 'A' and 'Z' • Produce unique array index for this character • Increment this array element 4 4(b) DECLARE Index : INTEGER DECLARE Count : INTEGER FOR Count ← 1 TO LENGTH(InString) NextChar ← UCASE(MID(InString, Count, 1)) IF NextChar >= 'A' AND NextChar <= 'Z' THEN Index ← ASC(NextChar) – 64 Result[Index] ← Result[Index] + 1 ENDIF ENDFOR FOR Index ← 1 TO 26 OUTPUT "Letter " & CHR(Index + 64) & " : " & NUM_TO_STRING(Result[Index]) ENDFOR One mark for each of the following (max 7): 1 First loop from 1 to length of InString: 2 Extract each character in turn in a loop 3 Check that character is alphabetic (must cater for lower & upper case) in a loop 4 Obtain array index using ASC() - 64 in a loop 5 Increment element of Result array in a loop 6 Second loop from 1 to 26: 7 Attempt to OUTPUT character A to Z and corresponding count in a loop 8 Fully complete OUTPUT including any necessary type conversion in a loop 7
Mark scheme, page 9
9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2019 © UCLES 2019 Page 9 of 15 Question Answer Marks 5(a) One mark for each point. A valid string must contain: • At least two // more than one upper case character(s) • At least five // more than four lower case character(s) • More digit characters than 'other' characters 3
Mark scheme, page 10
9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2019 © UCLES 2019 Page 10 of 15 Question Answer Marks 5(b)(i) One mark for each area as outlined: Index NextChar Upper Lower Digit Other 0 0 0 0 1 'J' 1 2 'i' 1 3 'm' 2 4 '+' 1 5 'S' 2 6 'm' 3 7 'i' 4 8 't' 5 9 'h' 6 10 '*' 2 11 '9' 1 12 '9' 2 5 5(b)(ii) One mark per bullet point: • Returned value is FALSE • Digit – Other is not greater than zero // Number of Digit same as Other 2
Mark scheme, page 11
9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2019 © UCLES 2019 Page 11 of 15 Question Answer Marks 6(a) To retain data when the computer is shut down / turned off // after the program ends Accept equivalent answer. 1 6(b) 'Pseudocode' solution included here for development and clarification of mark scheme. Programming language example solutions appear in the Appendix. FUNCTION SearchFileNtoZ(AccNum : STRING) RETURNS BOOLEAN DECLARE FileData : STRING DECLARE Found : BOOLEAN CONSTANT SearchFile = "UserListNtoZ.txt" Found ← FALSE OPENFILE SearchFile FOR READ WHILE NOT EOF(SearchFile) AND NOT Found READFILE SearchFile, FileData IF AccNum & '*' = LEFT(FileData, LENGTH(AccNum)+ 1) THEN Found ← TRUE ENDIF ENDWHILE CLOSEFILE SearchFile RETURN Found ENDFUNCTION One mark for each of the following: 1. Function heading and ending, (ignore parameter) and returned BOOLEAN 2. File OPEN UserListNtoZ.txt in READ mode and CLOSE 3. Conditional loop repeating until EOF() or 'Found' 4. Read a line from the file in a loop 5. Compare the correct number of characters with AccNum in a loop 6. Set termination logic if found in a loop 7. Return Boolean value 7
Mark scheme, page 12
9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2019 © UCLES 2019 Page 12 of 15 Question Answer Marks 6(c) PROCEDURE FindDuplicates() DECLARE Index : INTEGER DECLARE FileData : STRING DECLARE Continue : BOOLEAN DECLARE AccNum : STRING Index ← 1 // assuming array is [1:100] Continue ← TRUE OPENFILE "UserListAtoM.txt" FOR READ WHILE NOT EOF("UserListAtoM.txt") AND Continue = TRUE READFILE "UserListAtoM.txt", FileData IF MID(FileData, 7, 1) = '*' // six character reference THEN AccNum ← LEFT(FileData, 6) ELSE AccNum ← LEFT(FileData, 9) ENDIF IF SearchFileNtoZ(AccNum) = TRUE THEN IF Index = 101 // is the array already full? THEN OUTPUT "Error – Array Full" Continue ← FALSE ELSE Duplicates[Index] ← AccNum Index ← Index + 1 ENDIF ENDIF ENDWHILE CLOSEFILE "UserListAtoM.txt" ENDPROCEDURE One mark for each of the following (max 8): 1. Declaration and Initialisation of Index and used to index array Duplicates 2. OPEN file UserListAtoM.txt in READ mode and CLOSE 3. Pre-Condition loop to go through the file until EOF() and early termination if array full 4. Read line from file and extract account number (AccNum) in a loop 5. Call SearchFileNtoZ (with AccNum) following an attempt at MP4 in a loop 6. Check if return value is TRUE and if so: in a loop 7. store AccNum in correct array element 8. increment array index following an attempt at MP7 9. If array overflow OUTPUT error message 8
Mark scheme, page 13
9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2019 © UCLES 2019 Page 13 of 15 Question Answer Marks 6(d)(i) PROCEDURE ClearArray(BYREF ThisArray : ARRAY, NumElements : INTEGER, InitVal : STRING) DECLARE Index : INTEGER FOR Index ← 1 TO NumElements ThisArray[Index] ← InitVal ENDFOR ENDPROCEDURE Mark as follows: • Procedure header • Loop • Assignment within loop 3 6(d)(ii) 'Pseudocode' solution included here for development and clarification of mark scheme. Programming language example solutions appear in the Appendix. CALL ClearArray(Duplicates, 100, "Empty") Mark as follows: • Procedure call • Parameter list (in brackets) 2
Mark scheme, page 14
9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2019 © UCLES 2019 Page 14 of 15 Program Code Example Solutions Question 6(b): Visual Basic Function SearchFileNtoZ(ByVal SearchString As String) As Boolean Dim FileData As String Dim Found As Boolean Found = FALSE FileOpen(1, "UserListNtoZ.txt", OpenMode.Input) While Not EOF(1) And Not Found Filedata = LineInput(1) If SearchString & '*' = Left(FileData, Len(SearchString)+1) Then Found = TRUE End If End While FileClose(1) Return Found End Function Question 6(b): Pascal function SearchFileNtoZ (SearchString : string): boolean; var FileData : string; Found : boolean; MyFile : text; begin Found := FALSE; assign(MyFile, "UserListNtoZ.txt"); reset (Myfile); while Not EOF(MyFile) And Not Found do begin readLn(MyFile, FileData); if SearchString + '*' = LeftStr(FileData, length(SearchString)+1) then Found := TRUE; end; close(MyFile); result := Found; // SearchFileB := Found; end;
Mark scheme, page 15
9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2019 © UCLES 2019 Page 15 of 15 Question 6(b): Python def SearchFileNtoZ(SearchString): ## FileData : String ## Found : Boolean ## MyFile : Text Found = False MyFile = open("UserListNtoZ.txt", 'r') FileData = MyFile.readline() while Filedata != "" and not Found : if SearchString + '*' == FileData[0: len(SearchString)+1]: Found = True FileData = MyFile.readline() MyFile.close return(Found) Question 6(d)(ii): Visual Basic Call ClearArray(Duplicates, 100, "Empty") 'Call optional Question 6(d)(ii): Pascal ClearArray(Duplicates, 100, 'Empty'); Question 6(d)(ii): Python ClearArray(Duplicates, 100, "Empty")
What you needed in this session
Cambridge’s own grade thresholds for 2019 Oct/Nov, Paper 2 · Variant 1. A higher threshold means an easier paper — the bar moves with how the cohort did.