Cambridge A Level Computer Science 9608 — 2019 Oct/Nov Paper 2 · Variant 3
9608/23/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 paper16 pages
















Mark scheme13 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/SG) 171122/4 © UCLES 2019 [Turn over * 9 5 3 4 4 8 1 8 7 2 * COMPUTER SCIENCE 9608/23 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/23/O/N/19 © UCLES 2019 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 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.
Question paper, page 3
3 9608/23/O/N/19 © UCLES 2019 [Turn over 1 (a) (i) Programming languages can support different data types. Complete the table by naming three different data types together with an example data value for each. Data type Example data value [6] (ii) Identify the type of programming statement that assigns a data type to a variable. … [1] (b) As part of the development of an algorithm, a programmer may construct an identifier table. Describe what an identifier table contains. … … … … [2] (c) (i) Simple algorithms usually consist of three different stages. Complete the table below. Write each example statement in program code. The second stage has already been given. Stage Example statement Process [5] (ii) Write a single statement in program code that contains two of the stages. Do not repeat any of the statements from part (c)(i). … [1]
Question paper, page 4
4 9608/23/O/N/19 © UCLES 2019 (d) A software developer is writing a program and includes several features to make it easier to read and understand. One of these features is the use of indentation. State three other features. Feature 1 … Feature 2 … Feature 3 … [3] (e) A trace table is often used during program testing. Identify the type of testing that includes the use of a trace table. … [1]
Question paper, page 5
5 9608/23/O/N/19 © UCLES 2019 [Turn over 2 (a) (i) Two types of loop that may be found in an algorithm are the ‘pre-condition’ and ‘post- condition’ loop. Identify one other type of loop. Explain when it should be used. Type … Explanation … … … [2] (ii) Part of a program flowchart is shown. LOOP AlarmReset() Set Status1 to GetStatus(Sys_A) Set Status2 to GetStatus(Sys_B) Are Status1 and Status2 both TRUE? NO YES Implement the flowchart in pseudocode using a post-condition loop. … … … … … … [4]
Question paper, page 6
6 9608/23/O/N/19 © UCLES 2019 (b) The following lines of code are taken from a high-level language program. 100 setvar(Count, Integer) 110 setvar(Gross[0-20], Real) 120 setvar(Posn, Real) 130 setvar(Length, Integer) 140 setvar(Rate, Real) 150 Length := 7 160 Rate := 1.175 170 180 For (Count, 0, 20, 2) 190 { 200 Echo "Input next cost" 210 Posn := Read() 220 Gross[Count] := Mult(Posn, Rate) %Apply current tax rate 230 } Study the code. Identify the relevant features in the following table. Feature Answer The symbol used to indicate an assignment The line numbers for the start and end of a count-controlled loop The step value of the count-controlled loop The character that indicates a comment The name of a function [5] (c) A program written in a high-level language cannot be run directly. Identify one type of translator that can be used to translate the program. … [1]
Question paper, page 7
7 9608/23/O/N/19 © UCLES 2019 [Turn over 3 Three program modules process updating of passwords in a file. A description of the relationship between the modules is summarised as follows: Module name Description GetPassword() • Takes two parameters: AccountID and OldPassword • Returns a string containing the new password UpdateFile() • Takes two parameters: AccountID and NewPassword • Returns a Boolean value to indicate whether or not the update was successful ChangePassword() • Calls GetPassword() to obtain the new password then calls UpdateFile() to write the new password to the file Draw a structure chart to show the relationship between the three modules and the parameters passed between them. [5]
Question paper, page 8
8 9608/23/O/N/19 © UCLES 2019 4 The following pseudocode algorithm checks whether a string is a valid email address. FUNCTION Check(InString : STRING) RETURNS BOOLEAN DECLARE Index : INTEGER DECLARE NumDots : INTEGER DECLARE NumAts : INTEGER DECLARE NextChar : CHAR DECLARE NumOthers : INTEGER NumDots 0 NumAts 0 NumOthers 0 FOR Index 1 TO LENGTH(InString) NextChar MID(InString, Index, 1) CASE OF NextChar '.': NumDots NumDots + 1 '@': NumAts NumAts + 1 OTHERWISE NumOthers NumOthers + 1 ENDCASE ENDFOR IF (NumDots >= 1 AND NumAts = 1 AND NumOthers > 5) 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 9
9 9608/23/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 Check("Jim.99@skail.com") Index NextChar NumDots NumAts NumOthers [5] (ii) State the value returned when function Check is called as shown in part (b)(i). … [1]
Question paper, page 10
10 9608/23/O/N/19 © UCLES 2019 (c) The function Check() is to be tested. State two different invalid string values that could be used to test the algorithm. Each string should test a different rule. Justify your choices. Value … Justification … … … Value … Justification … … … [4] 5 Abbreviations are often used in place of a full name. Concatenating the first letter of each word in the name makes an abbreviation. For example: Name Abbreviation United Nations UN World Wide Web WWW British Computer Society BCS A function, Abbreviate(), will take a string representing the full name and return a string containing the abbreviated form. You should assume that: • names only contain alphabetic characters and space characters • names always start with an alphabetic character • each word in the name always starts with an uppercase character • only a single space separates words in the name.
Question paper, page 11
11 9608/23/O/N/19 © UCLES 2019 [Turn over Write pseudocode to implement the function Abbreviate(). Refer to the Appendix on page 16 for the list of built-in functions and operators. … … … … … … … … … … … … … … … … … … … … … … … … … … [8]
Question paper, page 12
12 9608/23/O/N/19 © UCLES 2019 6 A text file, Library.txt, stores information relating to a book collection. The file stores four pieces of information about each book on separate lines of the file, as follows: Line n: <Book Title> Line n + 1: <Author Name> Line n + 2: <ISBN> Line n + 3: <Location> Information is stored as data strings. Information relating to two books is shown: File line Data 100 "Learning Python" 101 "Brian Smith" 102 "978-14-56543-21-8" 103 "BD345" 104 "Surviving in the mountains" 105 "C T Snow" 106 "978-35-17635-43-9" 107 "ZX001" (a) (i) A function, FindBooksBy(), will search Library.txt for all books by a given author. The function will store the Book Title and Location in the array Result, and will return a count of the number of books found. Array Result is a global 2D array of type STRING. It has 100 rows and 2 columns. Write pseudocode to declare the array Result. … … … [3] (ii) Function FindBooksBy() will: • receive the Author Name as a parameter • search Library.txt for matching entries • store the Book Title and Location of matching entries in the Result array • return an integer value giving the number of books by the author that were found.
Question paper, page 13
13 9608/23/O/N/19 © UCLES 2019 [Turn over Write program code for the function FindBooksBy(). 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 … … … … … … … … … … … … … … … … … … … … … … … …
Question paper, page 14
14 9608/23/O/N/19 © UCLES 2019 … … … … … … [8] (b) The function FindBooksBy() has already been called and has stored values in the array Result. The procedure, DisplayResults(), will output the information from the array. The procedure receives the following two parameters: • a string containing the author name • an integer value representing the number of books found The output should be formatted as in the following example: Books written by: Brian Smith Title Location Learning Python BD345 Arrays are not lists CZ562 Learning Java CZ589 Number of titles found: 3 If no books by the author are found, the following should be output: Search found no books by: Brian Smith
Question paper, page 15
15 9608/23/O/N/19 © UCLES 2019 [Turn over Write pseudocode for the procedure DisplayResults(). Refer to the Appendix on page 16 for the list of built-in functions and operators. … … … … … … … … … … … … … … … … … … … … … [7]
Question paper, page 16
16 9608/23/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 ASC(ThisChar : CHAR) RETURNS INTEGER returns the ASCII value of ThisChar Example: ASC('A') returns 65 MOD(ThisNum : INTEGER, ThisDiv : INTEGER) RETURNS INTEGER returns the integer value representing the remainder when ThisNum is divided by ThisDiv Example: MOD(10,3) returns 1 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 2019 [Turn over Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level COMPUTER SCIENCE 9608/23 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/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2019 © UCLES 2019 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 2019 © UCLES 2019 Page 3 of 13 Question Answer Marks 1(a)(i) One mark for each (different) data type ... ... and one mark for a corresponding example value Acceptable types: Integer, Real, String, Char, Boolean, Date, 6 1(a)(ii) Declaration 1 1(b) Two from (max 2): • A list of identifier / variable names • Explanations/descriptions (of what they are used for) • Data types 2 1(c)(i) One mark for each stage (Input, Output) One mark for each correct example Stage Example statement Input Next = Console.Readline() Process x = INT(y/3) Output Console.Writeline("Goodbye") 5 1(c)(ii) One mark for statement in program code that includes (at least) two 'stages' Example correct answers: • Next = LEN(Console.Input()) • Console.writeline(Name & Address) • Console.WriteLine(Console.Readline() & " is what you entered") 1 1(d) Three from the following (max 3): • Blank lines • Capitalisation of Keywords • Sensible variable names • Use of (library/built-in) functions • Comments • PrettyPrint / keywords coloured 3 1(e) White-box 1
Mark scheme, page 4
9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2019 © UCLES 2019 Page 4 of 13 Question Answer Marks 2(a)(i) • Count-controlled // FOR loop • Used when the number of iterations is known / fixed 2 2(a)(ii) REPEAT CALL AlarmReset() Status1 ← GetStatus(Sys_A) Status2 ← GetStatus(Sys_B) UNTIL (Status1 = TRUE AND Status2 = TRUE) One mark for each of: 1 REPEAT ... UNTIL 2 Call to AlarmReset() 3 Asignment of Status1 and Status2 4 correct logical test 4 2(b) Feature Answer The symbol used to indicate an assignment := The line numbers for the start and end of a count- controlled loop 180/190 and 230 The step value of the count-controlled loop 2 The character that indicates a comment % The name of a function Mult // Read 5 2(c) Compiler / Interpreter 1
Mark scheme, page 5
9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2019 © UCLES 2019 Page 5 of 13 Question Answer Marks 3 One mark for each of the following: • all three boxes correctly labelled • parameters in to GetPassword() • value back from GetPassword() • parameters in to UpdateFile() • BOOLEAN value back from UpdateFile() 5 Question Answer Marks 4(a) One mark for each point. Valid string must contain: • at least one '.' characters • one '@' character • more than 5 other characters. 3
Mark scheme, page 6
9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2019 © UCLES 2019 Page 6 of 13 Question Answer Marks 4(b)(i) One mark for each area as outlined: Index NextChar NumDots NumAts NumOthers 0 0 0 1 'J' 1 2 'i' 2 3 'm' 3 4 '.' 1 5 '9' 4 6 '9' 5 7 '@' 1 8 's' 6 9 'k' 7 10 'a' 8 11 'i' 9 12 'l' 10 13 '.' 2 14 'c' 11 15 'o' 12 16 'm' 13 5 4(b)(ii) TRUE 1
Mark scheme, page 7
9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2019 © UCLES 2019 Page 7 of 13 Question Answer Marks 4(c) One mark for string and one mark for correct explanation. Same for second answer providing it results in a different path through the algorithm. Correct answers may be: • without the correct number of '.' • without the correct number of '@' • without the correct number of 'other characters' 4
Mark scheme, page 8
9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2019 © UCLES 2019 Page 8 of 13 Question Answer Marks 5 FUNCTION Abbreviate(Name : STRING) RETURNS STRING DECLARE NewString : STRING DECLARE NextChar : CHAR DECLARE Index : INTEGER DECLARE Space : BOOLEAN CONSTANT SPACECHAR = ' ' Space ← TRUE NewString ← "" FOR Index ← 1 TO LENGTH(Name) NextChar ← MID(Name,Index,1) IF Space = TRUE THEN NewString ← NewString & NextChar // first char of next word Space ← FALSE ELSE IF NextChar = SPACECHAR THEN Space ← TRUE ENDIF ENDIF ENDFOR RETURN NewString ENDFUNCTION 1 mark for each of the following (max 8): 1 Function header, ending and return parameters 2 Declare and Initialise NewString to either "" or first character of name 3 FOR loop picking out all characters from Name: 4 extract an individual character in a loop 5 check for space character in a loop 6 concatenate the next character to NewString in a loop 7 Return NewString 8 Accommodate a string with trailing space 8 Question Answer Marks 6(a)(i) One mark per underlined section: DECLARE Result : ARRAY [0:99, 0:1] OF STRING 3
Mark scheme, page 9
9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2019 © UCLES 2019 Page 9 of 13 Question Answer Marks 6(a)(ii) 'Pseudocode' solution included here for development and clarification of mark scheme. Programming language example solutions appear in the Appendix. FUNCTION FindBooksBy(SearchAuthor : STRING) RETURNS INTEGER DECLARE Title : STRING DECLARE Author : STRING DECLARE Isbn : STRING DECLARE Location : STRING DECLARE Count : INTEGER Count ← 0 OPENFILE "Library.txt" FOR READ WHILE NOT EOF ("Library.txt") READFILE "Library.txt", Title READFILE "Library.txt", ThisAuthor READFILE "Library.txt", ISBN READFILE "Library.txt", Location IF SearchAuthor = ThisAuthor THEN Result[Count, 0] ← Title Result[Count, 1] ← Location Count ← Count + 1 ENDIF ENDWHILE CLOSEFILE("Library.txt") RETURN Count ENDFUNCTION One mark for each of the following: 1 Function heading (and ending) including parameters 2 Declaration of variables used 3 Open file for reading (Allow Library or Library.txt) 4 WHILE loop checking for EOF(): 5 Read all information 'fields', in the correct order, in a loop 6 If the author matches write Title and Location to Result array in a loop 7 And increment array index in a loop // number found 8 Close file and RETURN Count 8
Mark scheme, page 10
9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2019 © UCLES 2019 Page 10 of 13 Question Answer Marks 6(b) PROCEDURE DisplayResults(Author:STRING, Count:INTEGER) DECLARE Index, GLen : INTEGER DECLARE Gap : STRING Gap ← " " // 25 spaces IF Count = 0 THEN OUTPUT "Search found no books by: " & Author ELSE OUTPUT "Books written by: " & Author OUTPUT "Title" & LEFT(Gap, 20) & "Location" FOR Index ← 1 TO Count GLen ← 25 – LENGTH(Result[Index, 0]) OUTPUT Result[Index, 0] & LEFT(Gap, GLen) & Result[Index, 1] ENDFOR OUTPUT "Number of titles found: " & NUM_TO_STRING(Count) ENDIF ENDPROCEDURE One mark for each of the following (max 7): 1 Procedure heading and ending including parameters 2 Declaration of local INTEGER variable for use as index 3 Test if count = 0 and if so output suitable message including Author for no books found otherwise output the two header strings (exact format not important) 4 A FOR loop for Count times 5 ... output two array elements from Result array in a loop 6 Final output statement 7 A reasonable attempt at calculating the number of spaces required to align 'Location' column: 8 Alignment correct 7
Mark scheme, page 11
9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2019 © UCLES 2019 Page 11 of 13 Program Code Example Solutions Q6 (a) (ii): Visual Basic FUNCTION FindBooksBy(ByVal SearchAuthor As String) As Integer Dim Title As String Dim Author As String Dim Isbn As String Dim Location As String Dim Count As Integer Count = 0 FileOpen(1, "Library.txt", OpenMode.Input) While Not EOF(1) Title = LineInput(1) ThisAuthor = LineInput(1) Isbn = LineInput(1) Location = LineInput(1) If SearchAuthor = ThisAuthor Then Result(Count, 0) = Title Result(Count, 1) = Location Count = Count + 1 End If End While FileClose(1) Return Count END FUNCTION
Mark scheme, page 12
9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2019 © UCLES 2019 Page 12 of 13 Q6 (a) (ii): Pascal function FindBooksBy(SearchAuthor : string) : integer; var Title : string; Author : string; Isbn : string; Location : string; Count : integer; MyFile : text; begin Count := 0; assign(MyFile, 'Library.txt'); reset(MyFile); while not EOF(MyFile) do begin readln(MyFile, Title); readln(MyFile, ThisAuthor); readln(MyFile, Isbn); readln(MyFile, Location); if SearchAuthor = ThisAuthor then begin Result[Count, 0] := Title; Result[Count, 1] := Location; Count := Count + 1; end; end; close(MyFile); FindBooksBy := Count; end;
Mark scheme, page 13
9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2019 © UCLES 2019 Page 13 of 13 Q6 (a) (ii): Python def FindBooksBy(SearchAuthor): ## Title : STRING ## Author : STRING ## Isbn : STRING ## Location : STRING ## Count : INTEGER Count = 0 MyFile = open("Library.txt", 'r') Title = MyFile.readline() while Title != "": ThisAuthor = MyFile.readline() Isbn= MyFile.readline() Location = MyFile.readline() if SearchAuthor == ThisAuthor.strip(): Result[Count][0] = Title Result[Count][1] = Location Count = Count + 1 Title = MyFile.readline() MyFile.close() return(Count)
What you needed in this session
Cambridge’s own grade thresholds for 2019 Oct/Nov, Paper 2 · Variant 3. A higher threshold means an easier paper — the bar moves with how the cohort did.