Cambridge A Level Computer Science 9608 — 2020 May/June Paper 4 · Variant 2

9608/42/M/J/20

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 papers

Question paper16 pages

Cambridge A Level Computer Science 9608 2020 May/June Paper 4 · Variant 2 question paper, page 1 of 16
Page 1 of 16
Cambridge A Level Computer Science 9608 2020 May/June Paper 4 · Variant 2 question paper, page 2 of 16
Page 2 of 16
Cambridge A Level Computer Science 9608 2020 May/June Paper 4 · Variant 2 question paper, page 3 of 16
Page 3 of 16
Cambridge A Level Computer Science 9608 2020 May/June Paper 4 · Variant 2 question paper, page 4 of 16
Page 4 of 16
Cambridge A Level Computer Science 9608 2020 May/June Paper 4 · Variant 2 question paper, page 5 of 16
Page 5 of 16
Cambridge A Level Computer Science 9608 2020 May/June Paper 4 · Variant 2 question paper, page 6 of 16
Page 6 of 16
Cambridge A Level Computer Science 9608 2020 May/June Paper 4 · Variant 2 question paper, page 7 of 16
Page 7 of 16
Cambridge A Level Computer Science 9608 2020 May/June Paper 4 · Variant 2 question paper, page 8 of 16
Page 8 of 16
Cambridge A Level Computer Science 9608 2020 May/June Paper 4 · Variant 2 question paper, page 9 of 16
Page 9 of 16
Cambridge A Level Computer Science 9608 2020 May/June Paper 4 · Variant 2 question paper, page 10 of 16
Page 10 of 16
Cambridge A Level Computer Science 9608 2020 May/June Paper 4 · Variant 2 question paper, page 11 of 16
Page 11 of 16
Cambridge A Level Computer Science 9608 2020 May/June Paper 4 · Variant 2 question paper, page 12 of 16
Page 12 of 16
Cambridge A Level Computer Science 9608 2020 May/June Paper 4 · Variant 2 question paper, page 13 of 16
Page 13 of 16
Cambridge A Level Computer Science 9608 2020 May/June Paper 4 · Variant 2 question paper, page 14 of 16
Page 14 of 16
Cambridge A Level Computer Science 9608 2020 May/June Paper 4 · Variant 2 question paper, page 15 of 16
Page 15 of 16
Cambridge A Level Computer Science 9608 2020 May/June Paper 4 · Variant 2 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

Cambridge International AS & A Level * 1 5 9 6 0 8 4 0 8 9 * DC (PQ) 182206/3 © UCLES 2020 [Turn over This document has 16 pages. Blank pages are indicated. COMPUTER SCIENCE 9608/42 Paper 4 Further Problem-solving and Programming Skills May/June 2020 2 hours You must answer on the question paper. No additional materials are needed. INSTRUCTIONS ● Answer all questions. ● Use a black or dark blue pen. ● Write your name, centre number and candidate number in the boxes at the top of the page. ● Write your answer to each question in the space provided. ● Do not use an erasable pen or correction fluid. ● Do not write on any bar codes. ● You may use an HB pencil for any diagrams, graphs or rough working. ● Calculators must not be used in this paper. INFORMATION ● The total mark for this paper is 75. ● The number of marks for each question or part question is shown in brackets [ ]. ● No marks will be awarded for using brand names of software packages or hardware.

Question paper, page 2

2 9608/42/M/J/20 © UCLES 2020 1 Amar is alerted to a run-time error when he runs a program. (a) A run-time error occurs when Amar attempts to open a file that does not exist. State three other reasons why a run-time error may occur. 1 … … 2 … … 3 … … [3] (b) A program should be written with exception handling routines to manage run-time errors. A program reads data from the text file MyData.txt. The program needs to report an exception if it attempts to open the file and the file does not exist. Write program code to handle and report this exception. Programming language … Program code … … … … … … … … … [2]

Question paper, page 3

3 9608/42/M/J/20 © UCLES 2020 [Turn over 2 A business is developing a program that stores each customer’s username and password in a hash table. The hash table will be implemented as a 1D array, CustomerLogIn, of the custom data type CustomerRecord. The declaration for CustomerRecord is: TYPE CustomerRecord DECLARE Username : STRING DECLARE Password : STRING ENDTYPE The hash table will store a maximum of 3000 records. The key field will be Username. (a) The program declares the hash table and initialises the username and password of all the records to an empty string. Write pseudocode to declare and initialise the hash table. … … … … … … … … [4]

Question paper, page 4

4 9608/42/M/J/20 © UCLES 2020 (b) (i) A function, SearchHashTable() will search for a customer’s record in the hash table. The function Hash(): • takes a Username as a parameter • performs the hashing algorithm • returns the calculated index of the username within the hash table. The function SearchHashTable(): • takes the username to search for as a parameter • uses Hash() to calculate the first index of this username within the hash table • returns either the index of the username if found, or –1 if not found. Complete the pseudocode for the function SearchHashTable(). FUNCTION SearchHashTable(BYVALUE SearchUser : STRING) RETURNS … DECLARE Index : INTEGER DECLARE Count : INTEGER Index … (SearchUser) Count 0 WHILE (CustomerLogIn[Index] … <> …) AND(CustomerLogIn[Index].Username <> "") AND(Count < 2999) Index Index + 1 Count Count + 1 IF Index > … THEN Index 0 ENDIF ENDWHILE IF CustomerLogIn[Index].Username = … THEN RETURN Index ELSE RETURN … ENDIF ENDFUNCTION [7]

Question paper, page 5

5 9608/42/M/J/20 © UCLES 2020 [Turn over (ii) Explain the purpose of the variable Count in the function SearchHashTable(). … … … … [2] 3 Recursive algorithms can be used when creating programs. (a) Describe what is meant by a recursive algorithm. … … … … … … [3]

Question paper, page 6

6 9608/42/M/J/20 © UCLES 2020 (b) A string that is a palindrome, reads the same forwards as it does backwards. For example, the name Anna is a palindrome. The function Substring(Variable, StartingCharacter, NumberOfCharacters) returns one or more characters from a string. The first character is at position 0. For example, the string "Happy" is stored in the variable Word. • Substring(Word, 1, 1) would return the character "a". • Substring(Word, 2, 3) would return the characters "ppy". The function Length() returns the length of the string as an integer. For example, Length(Word) returns 5. The following is a recursive function to find out whether a string is a palindrome. The function returns True if the parameter is a palindrome, and returns False if it is not a palindrome. Complete the pseudocode for the recursive algorithm to indicate whether a string is a palindrome. FUNCTION IsPalindrome(CheckWord : STRING) RETURNS BOOLEAN IF … <= 1 THEN RETURN … ENDIF IF Substring(CheckWord, 0, 1) <> Substring(CheckWord, … (CheckWord)-1, 1) THEN RETURN … ELSE RETURN …( Substring(CheckWord, 1, Length(CheckWord)-2)) ENDIF ENDFUNCTION [5]

Question paper, page 7

7 9608/42/M/J/20 © UCLES 2020 [Turn over (c) The function FindPower() is a recursive function that calculates the result of a base number to the power of the exponent. For example, the result of 24 = 16, as 2*2*2*2 = 16. In this example, 2 is the base number and 4 is the exponent. The base number and the exponent are passed as parameters. Write pseudocode for the recursive function FindPower(). Assume both the base and the exponent are positive integers. … … … … … … … … … … … … [5]

Question paper, page 8

8 9608/42/M/J/20 © UCLES 2020 4 (a) A tennis club has a booking form to book lessons with an instructor. Club members can book up to five lessons using the booking form. The customer details section has the data: • name • address • telephone number. The lesson details section has the data: • lesson type • date and time • lesson cost. The cost of each lesson is dependent on the customer’s type of membership. The membership can be bronze, silver or gold. The total cost is also calculated. Complete the following JSP data structure diagram for the booking form. Customer Details Total Cost Booking Form [7]

Question paper, page 9

9 9608/42/M/J/20 © UCLES 2020 [Turn over (b) State two programming constructs that are shown in a JSP data structure diagram. 1 … … 2 … … [2]

Question paper, page 10

10 9608/42/M/J/20 © UCLES 2020 5 A declarative programming language is used to represent the following knowledge base. 01 person(william). 02 person(deeraj). 03 person(ingrid). 04 person(meghan). 05 country(england). 06 country(spain). 07 country(bangladesh). 08 country(new_zealand). 09 country(malaysia). 10 country(mauritius). 11 visited(william, spain). 12 visited(ingrid, new_zealand). 13 visited(deeraj, spain). 14 visited(meghan, spain). These clauses have the following meanings: Clause Meaning 02 Deeraj is a person 05 England is a country 11 William has visited Spain (a) Gina is a person who has visited Cyprus. Write additional clauses to represent this information. 15 … 16 … 17 … [3] (b) Write the result returned by the goal: visited(X, spain). X = … [2] (c) P might visit C, if P is a person, C is a country and P has not visited C. Write this as a rule. mightvisit(P , C) IF … … … [4]

Question paper, page 11

11 9608/42/M/J/20 © UCLES 2020 [Turn over 6 Object-oriented programming has several features. These include containment, classes, methods and properties. (a) Describe what is meant by containment. … … … … … … [3] (b) Identify two other features of object-oriented programming. 1 … 2 … [2]

Question paper, page 12

12 9608/42/M/J/20 © UCLES 2020 7 A programmer is creating a computer game. The programmer has designed the class, Character, for the characters in the game. The following class diagram shows the design for the Character class. Character Name : STRING Skill : INTEGER Health : INTEGER Shield : INTEGER // // // // initialised in constructor to the parameter value passed to the constructor initialised in constructor to 0 initialised in constructor to 50 initialised in constructor to a random value between 1 and 25 (inclusive) Constructor() GetName() GetSkill() GetHealth() GetShield() SetSkill() SetHealth() SetShield() // // // // // // // // method used to create and initialise an object returns Name value returns Skill value returns Health value returns Shield value increases Skill by the parameter value increases or decreases Health by the parameter value increases or decreases Shield value by the parameter value (a) Write program code for the Constructor() method. Use the appropriate constructor method for your chosen programming language. Programming language … Program code … … … … … … … … … … … …

Question paper, page 13

13 9608/42/M/J/20 © UCLES 2020 [Turn over … … … … … [5] (b) Write program code for the GetSkill() method. Programming language … Program code … … … … … [2]

Question paper, page 14

14 9608/42/M/J/20 © UCLES 2020 (c) The method SetSkill() validates the parameter value and updates the value of Skill. The method is passed an INTEGER parameter that must be between 10 and 25 (inclusive). A value outside of this is not valid. If the parameter value is valid, the method will increase Skill by the parameter value. The maximum value that Skill can be increased to is 200. For example: • Skill currently stores 180 • it is passed a valid parameter value of 25 • Skill will now store 200. The method must return: • –1 if the parameter value is not valid • 1 if the value of Skill is updated and Skill is less than 200 • 0 if the value of Skill is 200. Write program code for the SetSkill() method. Programming language … Program code … … … … … … … … … … … … [6]

Question paper, page 15

15 9608/42/M/J/20 © UCLES 2020 [Turn over (d) There are five characters in the game. All the character objects are stored in a 1D array. Write pseudocode to declare the array, CharacterArray, to store the five character objects. … … [2] (e) The game has the character with the name Victory. Write program code to create the character Victory as an instance of the class Character. The object needs to be stored in the first element of the array CharacterArray. Programming language … Program code … … … [3] Question 8 begins on the next page.

Question paper, page 16

16 9608/42/M/J/20 © UCLES 2020 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. 8 Files can be structured in serial, sequential or random format. Tick (3) one box in each row to show whether the statement applies to Serial, Sequential or Random format. Statement Serial Sequential Random Uses a hashing algorithm No key field is used when storing data, for example, it is stored in chronological order Collisions can occur Least efficient for a very large number of records Most efficient for a very large number of records [3]

Mark scheme, page 1

This document consists of 13 printed pages. © UCLES 2020 [Turn over Cambridge International AS & A Level COMPUTER SCIENCE 9608/42 Paper 4 Written Paper May/June 2020 MARK SCHEME Maximum Mark: 75 Published Students did not sit exam papers in the June 2020 series due to the Covid-19 global pandemic. This mark scheme is published to support teachers and students and should be read together with the question paper. It shows the requirements of the exam. The answer column of the mark scheme shows the proposed basis on which Examiners would award marks for this exam. Where appropriate, this column also provides the most likely acceptable alternative responses expected from students. Examiners usually review the mark scheme after they have seen student responses and update the mark scheme if appropriate. In the June series, Examiners were unable to consider the acceptability of alternative responses, as there were no student responses to consider. Mark schemes should usually be read together with the Principal Examiner Report for Teachers. However, because students did not sit exam papers, there is no Principal Examiner Report for Teachers for the June 2020 series. Cambridge International will not enter into discussions about these mark schemes. Cambridge International is publishing the mark schemes for the June 2020 series for most Cambridge IGCSE™ and Cambridge International A & AS Level components, and some Cambridge O Level components.

Mark scheme, page 2

9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2020 © UCLES 2020 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.

Mark scheme, page 3

9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2020 © UCLES 2020 Page 3 of 13 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 4

9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2020 © UCLES 2020 Page 4 of 13 Question Answer Marks 1(a) 1 mark per reason to max 3 e.g. • Division by zero • Array out of bounds • File does not exist • Stack overflow • Memory leakage • Hardware fault/failure 3 1(b) 1 mark per bullet point • Check if file exist • Reporting appropriate exception Python try: file = open('MyData.txt') except: print "No file found" Visual Basic (.net) Try Dim fileReader As New System.IO.StreamReader("MyData.txt") Catch ex As Exception console.writeline("No file found") End Try Pascal try Readln("MyData.txt") except Writeln("No file found") end; 2

Mark scheme, page 5

9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2020 © UCLES 2020 Page 5 of 13 Question Answer Marks 2(a) 1 mark per bullet point to max 4 • Declaration of array with 3000 elements • … of type CustomerRecord • Looping 3000 times • Accessing the username and password for each field • Correct initialisation of values to “” DECLARE CustomerLogIn : ARRAY[0:2999] OF CustomerRecord FOR x ← 0 TO 2999 CustomerLogIn[x].Username ← "" CustomerLogIn[x].Password ← "" ENDFOR 4

Mark scheme, page 6

9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2020 © UCLES 2020 Page 6 of 13 Question Answer Marks 2(b)(i) 1 mark for each correctly filled in space FUNCTION SearchHashTable(BYVALUE SearchUser : STRING) RETURNS INTEGER DECLARE Index : INTEGER DECLARE Count : INTEGER Index ← Hash(SearchUser) Count ← 0 WHILE (CustomerLogIn[Index].Username <> SearchUser) AND (CustomerLogIn[Index].Username <> "") AND (Count < 2999) Index ← Index + 1 Count ← Count + 1 IF Index > 2999 THEN Index ← 0 ENDIF ENDWHILE IF CustomerLogIn[Index].Username = SearchUser THEN RETURN Index ELSE RETURN -1 ENDIF ENDFUNCTION 7 2(b)(ii) 1 mark per bullet point to max 2 • Records if you have checked every record // the number of records checked in the array • … without finding the search value • … and stops infinite loop // stopping condition 2

Mark scheme, page 7

9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2020 © UCLES 2020 Page 7 of 13 Question Answer Marks 3(a) 1 mark per bullet point • Have a base case // stopping condition • Work toward the base case // general case // changes state • Call itself // defined in terms of itself 3 3(b) 1 mark for each (shown in bold) FUNCTION IsPalindrome(CheckWord : STRING) RETURNS BOOLEAN IF Length(CheckWord) <= 1 THEN RETURN True ENDIF IF Substring(CheckWord, 0, 1) <> Substring(CheckWord,Length(CheckWord)-1, 1) THEN RETURN False ELSE RETURN IsPalindrome(Substring(CheckWord,1, Length(CheckWord)-2)) ENDIF ENDFUNCTION 5

Mark scheme, page 8

9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2020 © UCLES 2020 Page 8 of 13 Question Answer Marks 3(c) 1 mark per bullet point • Function is defined and returns integer with correct parameters • Returns 1 if exponent is 0 // returns base if exponent is 1 • Calculates base to power with recursive call … • … with correct parameters • Returns result of calculation e.g. FUNCTION FindPower(Base:INTEGER, Exp: INTEGER) RETURNS INTEGER DECLARE Value : INTEGER IF Exp = 0 THEN RETURN 1 ELSE Value ← Base * FindPower(Base, Exp – 1) RETURN Value ENDIF ENDFUNCTION 5

Mark scheme, page 9

9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2020 © UCLES 2020 Page 9 of 13 Question Answer Marks 4(a) 1 mark per bullet point: • Name, Address and Telephone number beneath Customer details • Class Details (or equivalent) below booking form • … with appropriate iteration of entering Class Details • Class type, and Date and time beneath Class Details (or equivalent) • Cost beneath Class Details (or equivalent) … • … with Bronze, Silver and Gold below it (FT for name and position of Cost) … • … with selection (FT for name and position of B, S, G) e.g. 7 4(b) 1 mark for each feature to max 2 • Sequence • Selection • Iteration 2 Booking Form Customer Details Class Details * Telephone number Address Name Class type Date and time Cost Total Cost Silver Gold Bronze

Mark scheme, page 10

9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2020 © UCLES 2020 Page 10 of 13 Question Answer Marks 5(a) • person(gina) • country(cyprus) • visited(gina, cyprus) 3 5(b) 1 mark for 2 correct, 2 marks for 3 correct william deeraj meghan 2 5(c) 1 mark per bullet point • person(P) // country(C) • AND country(C) // AND person(P) • AND NOT // , NOT • visited(P, C) mightvisit(P, C) IF person (P) AND country (C) AND NOT visited(P, C) 4 Question Answer Marks 6(a) 1 mark per bullet point to max 3 • A class includes an instance of another class • Aggregation • … the contained object can exist outside of its super class • Composition • … object is declared and exists within its super class // object is destroyed when super class is destroyed 3 6(b) 1 mark per feature to max 2 e.g. • Inheritance • Polymorphism • Encapsulation • Private/public 2

Mark scheme, page 11

9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2020 © UCLES 2020 Page 11 of 13 Question Answer Marks 7(a) 1 mark per bullet point to max 5 • Method header and close (where applicable) … • … with correct parameter • Initialised Name to parameter value • Initialised Skill to 0 and Health to 50 • Initialised Shield to randomly generated value • … between 1 and 25 Python def __init__(self, CharacterName) : self.__Name = CharacterName self.__Skill = 0 self.__Health = 50 self.__Shield = random.randint(1, 25) Pascal Constructor Character.Create(CharacterName); begin Name := CharacterName; Skill: = 0; Health := 50; Shield: = random(1,25); end; Visual Basic (.net) Public Sub New(CharacterName) Name = CharacterName Skill = 0 Health = 50 Shield = End Sub 5

Mark scheme, page 12

9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2020 © UCLES 2020 Page 12 of 13 Question Answer Marks 7(b) 1 mark per bullet point • function header and close (where applicable) • returns Skill e.g. Python def GetSkill(self) : return self.__Skill Visual Basic (.net) public function GetSkill() AS Integer return(Skill) 2 7(c) 1 mark per bullet to max 6 • Function header and close (where applicable) • …Takes a parameter value • Check parameter is >= 10 and <=25 and returns -2 • Checks new Value of skill is not > 200 • …limits to 200 if over • …returns 0 • Updates skill value and returns 1 e.g. Python def SetSkill(self, Value) : if Value < 10 or Value > 25 : return -1 else : if self.__Skill + Value >= 200: Skill = 200 return 0 else : self.__Skill = self.__Skill + Value return 1 6

Mark scheme, page 13

9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2020 © UCLES 2020 Page 13 of 13 Question Answer Marks 7(d) • Array declaration of correct name and size • Correct data type used DECLARE CharacterArray : ARRAY[0:4] OF Character 2 7(e) 1 mark per bullet point • Object is created using constructor • "Victory" passed as parameter • Stored in correct index of array PYTHON CharacterArray[0] = Character("Victory") Visual Basic (.net) CharacterArray[0] = New Character("Victory") 3 Question Answer Marks 8 Statement Serial Sequential Random Uses a hashing algorithm  No key field is used when storing data e.g. it is in chronological order  Collisions can occur  Least efficient for a very large number of records  Most efficient for a very large number of records  3