Cambridge A Level Computer Science 9608 — 2021 Oct/Nov Paper 4 · Variant 1

9608/41/O/N/21 · 75 marks · ≈84 min

The question paper and its mark scheme, free to read here and free to download. This is Cambridge’s own paper, exactly as it was sat.

← All Computer Science papersWhat was in this paper?

Question paper20 pages

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

Mark scheme19 pages

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

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

Paper as text

Question paper, page 1

This document has 20 pages. Any blank pages are indicated. Cambridge International AS & A Level COMPUTER SCIENCE 9608/41 Paper 4 Further Problem-solving and Programming Skills October/November 2021 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. * 9 3 4 4 6 6 7 3 9 0 * DC (CJ/SW) 314249/4 © UCLES 2021 [Turn over

Question paper, page 2

2 9608/41/O/N/21 © UCLES 2021 1 Sandy is writing a program to process data in a stack. The stack is implemented as a 1D array, DataStack, which has up to 100 elements. The function Push(Value) stores Value on the stack and returns TRUE if Value was added to the stack, or FALSE if the stack is full. The function Pop() returns the item at the top of the stack, or returns –1 if the stack is empty. DataStack and TopPointer are declared as global. (a) Show the state of DataStack and its pointer after the following functions are executed on the current contents. Pop() Pop() Push(19) Pop() Push(50) TopPointer 3 Index Data [7] [6] [5] [4] [3] 8 [2] 6 [1] 20 [0] 10 [2]

Question paper, page 3

3 9608/41/O/N/21 © UCLES 2021 [Turn over (b) Write program code for the function Pop(). Programming language … Program code … … … … … … … … … … … … … [5] (c) Sandy has also used a queue in her program. Describe the ways in which a queue differs from a stack. … … … … … … [2]

Question paper, page 4

4 9608/41/O/N/21 © UCLES 2021 2 A grade generator program takes the mark a student obtained in a test as input. The program calculates and outputs the grade that matches the mark. The grade is either A, B, C, D or U. Complete the following JSP structure diagram for the grade generator program. GradeGenerator [4]

Question paper, page 5

5 9608/41/O/N/21 © UCLES 2021 [Turn over 3 The following pseudocode algorithm performs a binary search on the sorted array ThisArray. The algorithm returns either the location of SearchItem in the array, or –1 if SearchItem is not in the array. The function DIV returns the integer value of the division, for example, 11 DIV 2 returns 5. Complete the algorithm by writing the missing pseudocode statements. FUNCTION BinarySearch(ThisArray[], LowerBound, UpperBound, SearchItem : INTEGER) RETURNS INTEGER DECLARE Flag : BOOLEAN DECLARE Mid : INTEGER Flag -2 WHILE Flag <> -1 Mid LowerBound + ((UpperBound – LowerBound) DIV 2) IF …………………………………………………………… < …………………………………………………………… THEN RETURN …………………………………………………………… ELSE IF ThisArray[Mid] > SearchItem THEN UpperBound Mid …………………………………………………………… ELSE IF ThisArray[Mid] < SearchItem THEN LowerBound Mid …………………………………………………………… ELSE RETURN …………………………………………………………… ENDIF ENDIF ENDIF ENDWHILE ENDFUNCTION [6]

Question paper, page 6

6 9608/41/O/N/21 © UCLES 2021 4 Teachers in a school may work on Mondays, Tuesdays and Wednesdays. There are three time slots on each day: time slot 1, time slot 2 and time slot 3. A teacher is either busy or free. The school is using a declarative language to write a program to record which teachers are busy in each time slot on each day. The following knowledge base is used: 01 teacher(james). 02 teacher(jill). 03 teacher(karl). 04 teacher(kira). 05 day(monday). 06 day(tuesday). 07 day(wednesday). 08 timeSlot(1). 09 timeSlot(2). 10 timeSlot(3). 11 busy(james, monday, 1). 12 busy(james, tuesday, 2). 13 busy(karl, monday, 1). 14 busy(kira, wednesday, 3). These clauses have the following meaning: Clause Explanation 01 James is a teacher 05 Monday is a day 08 1 is a time slot 11 James is busy in time slot 1 on Monday (a) More facts need to be included. Fred is a teacher who is busy in time slot 1 on Tuesday. Write additional clauses for these facts. 15 … 16 … [2]

Question paper, page 7

7 9608/41/O/N/21 © UCLES 2021 [Turn over (b) Additional clauses are needed to identify whether Jill is busy in time slot 1 on Monday, Tuesday, or Wednesday. Write these additional clauses. 17 … 18 … 19 … [2] (c) Write a goal, using the variable X, to find all the teachers who are busy in time slot 3 on Monday. … … [1] (d) Write a rule to find whether a teacher X is free in a specific time slot Y on day Z. IsTeacherFree(X, Z, Y) IF … … … … [4]

Question paper, page 8

8 9608/41/O/N/21 © UCLES 2021 5 The recursive algorithm for the Recursion() function is defined in pseudocode as follows: FUNCTION Recursion(A, B : INTEGER) RETURNS INTEGER IF A <= 100 THEN RETURN 1 ELSE IF A > B THEN RETURN 5 + Recursion(A - 1, B) ELSE RETURN 10 + Recursion(A – 10, B) ENDIF ENDIF ENDFUNCTION (a) The function is called with the following pseudocode statement: OUTPUT Recursion(104, 102) Dry run the function and complete the trace table. Give the output the program will produce. Trace table: Function call A B Return value Output = … Working … … …

Question paper, page 9

9 9608/41/O/N/21 © UCLES 2021 [Turn over … … … [4] (b) Rewrite the function Recursion() in pseudocode, using an iterative algorithm. … … … … … … … … … … … … … … … [4]

Question paper, page 10

10 9608/41/O/N/21 © UCLES 2021 6 Kobi is writing an application that uses a record structure to store data. (a) (i) Describe what is meant by a record structure. … … … … [2] (ii) The record structure stores the unique ID number (a whole number), first name and last name of a customer. Write a pseudocode declaration for the record structure CustomerData. … … … … … … … [2] (b) Kobi’s application stores the records in a random access file. The function StoreRecord(): • takes a customer record as a parameter • uses the function CustomerHash() to calculate and return the hash value for its parameter • stores the customer record in the returned hash value address. Assume there are no collisions. Complete the following pseudocode algorithm to write a new record to the random access file. PROCEDURE StoreRecord(NewData : ………………………………………………………………………) HashValue CustomerHash(NewData.CustomerID) Filename "CustomerRecords.dat" OPENFILE Filename FOR ……………………………………………………………………… SEEK Filename, ……………………………………………………………………… PUTRECORD Filename, ……………………………………………………………………… …………………………………………………………………… Filename ENDPROCEDURE [5]

Question paper, page 11

11 9608/41/O/N/21 © UCLES 2021 [Turn over (c) Identify two typical features of a debugger and describe how Kobi could use each one during the development of the application. Feature 1 … … … … Feature 2 … … … … [4] (d) Give one benefit and one drawback of Kobi using a program generator whilst developing his application. Benefit … … Drawback … … [2]

Question paper, page 12

12 9608/41/O/N/21 © UCLES 2021 7 Sonya is writing a computer program that requires a user input. The user should input an integer between 1 and 100. Sonya wants to use exception handling. (a) Explain the reasons why Sonya should use exception handling in her program. … … … … [2] (b) Write program code to read in the number from the user and raise an exception if the data is not valid. Programming language … Program code … … … … … … … [3] (c) Give two other examples of where exception handling can be used in a program. 1 … 2 … [2]

Question paper, page 13

13 9608/41/O/N/21 © UCLES 2021 [Turn over 8 Data entered into a computer is stored in an ordered binary tree. The binary tree is stored in a 2D array, BinaryTree. The first element of the array is index 0. (a) The current contents of the binary tree are: 50 35 2 43 52 77 67 Complete the LeftPointer and RightPointer values in the following table for the binary tree shown. A null pointer is represented by –1. RootNode 0 Index LeftPointer Data RightPointer [0] 50 [1] 67 [2] 77 [3] 35 [4] 2 [5] 43 [6] 52 [7] [8] [9] [10] [2]

Question paper, page 14

14 9608/41/O/N/21 © UCLES 2021 (b) A post-order tree traversal outputs the left node, then the right node, then the root node. In the tree given in part (a), the post-order tree traversal would output: 2 43 35 52 77 67 50 Complete the following recursive pseudocode algorithm PostOrder(). PROCEDURE PostOrder(………………………………………………… : INTEGER) IF BinaryTree[RootNode, 0] <> -1 THEN ………………………………………………… (BinaryTree[RootNode, …………………………………………………]) ENDIF IF BinaryTree[RootNode, 2] <> -1 THEN ………………………………………………… (BinaryTree[RootNode, 2]) ENDIF OUTPUT BinaryTree[RootNode, …………………………………………………] ENDPROCEDURE [5]

Question paper, page 15

15 9608/41/O/N/21 © UCLES 2021 [Turn over BLANK PAGE

Question paper, page 16

16 9608/41/O/N/21 © UCLES 2021 9 A program uses a hashing algorithm to store data in the global array, StoredData. The first element of the array is index 0. The array has 10 000 integer elements. (a) Write a pseudocode declaration for the array StoredData and initialise each element to –1. … … … … [3] (b) The hashing algorithm calculates the remainder after dividing the data by 1000, and then adds 6 to it. The function AddItem() takes the data as a parameter. It calculates the index to store the data using the hashing algorithm. If there is a collision, the function: • checks the next index until it finds an index that does not have data in it • continues to search from the start of the array, if it reaches the end of the array. The function returns TRUE if the item was successfully added, and FALSE if the array is full. Write program code for the function AddItem(). Programming language … Program code … … … … … … … … … … … …

Question paper, page 17

17 9608/41/O/N/21 © UCLES 2021 … … … … … … … … … … … … … … … … [7]

Question paper, page 18

18 9608/41/O/N/21 © UCLES 2021 BLANK PAGE

Question paper, page 19

19 9608/41/O/N/21 © UCLES 2021 BLANK PAGE

Question paper, page 20

20 9608/41/O/N/21 © UCLES 2021 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 19 printed pages. © UCLES 2021 [Turn over Cambridge International AS & A Level COMPUTER SCIENCE 9608/41 Paper 4 Further Problem-solving and Programming Skills October/November 2021 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 2021 series for most Cambridge IGCSE™, Cambridge International A and AS Level components and some Cambridge O Level components.

Mark scheme, page 2

9608/41 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2021 © UCLES 2021 Page 2 of 19 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/41 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2021 © UCLES 2021 Page 3 of 19 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/41 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2021 © UCLES 2021 Page 4 of 19 Question Answer Marks 1(a) 1 mark for TopPointer 1 mark for correct data in stack TopPointer 2 Index Data [7] [6] [5] [4] [3] (8) [2] 50 [1] 20 [0] 10 2

Mark scheme, page 5

9608/41 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2021 © UCLES 2021 Page 5 of 19 Question Answer Marks 1(b) 1 mark per bullet point • Function header (and close where appropriate returning an integer) • Checking if stack is empty … • … and returning −1 if it is • If there is data in stack, decrementing TopPointer • (Otherwise) returning the top Value Example code: VB.NET Function Pop() Dim Value as Integer If TopPointer < 0 Then Return -1 Else Value = DataStack(TopPointer) TopPointer = TopPointer – 1 Return Value End if End Function Python def Pop(): if TopPointer < 0 : return -1 else: Value = DataStack(TopPointer) TopPointer= TopPointer – 1 return Value 5

Mark scheme, page 6

9608/41 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2021 © UCLES 2021 Page 6 of 19 Question Answer Marks 1(b) Pascal Function Pop(): integer; var Value : integer; begin if TopPointer < 0 then Pop := -1 else Value := DataStack(TopPointer); TopPointer := TopPointer – 1; Pop := Value end; 1(c) 1 mark per bullet point to max 2 • In a stack the last item in is the first out/LIFO and in a queue the first item in is the first out/FIFO • Queue can be circular, but a stack is linear • Stack only needs a pointer to the top (and can have a base pointer) and a queue needs a pointer to the front and the rear 2

Mark scheme, page 7

9608/41 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2021 © UCLES 2021 Page 7 of 19 Question Answer Marks 2 1 mark per bullet point • Input mark, calculate grade and output grade on level 1… • … in correct order • All grades below calculation • Selection only on the grades and no other iteration/selection anywhere 4 GradeGenerator Input mark Calculation grade = A grade = B grade = C grade = D grade = U Output grade

Mark scheme, page 8

9608/41 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2021 © UCLES 2021 Page 8 of 19 Question Answer Marks 3 1 mark for each completed statement FUNCTION BinarySearch(ThisArray, LowerBound, UpperBound, SearchItem: INTEGER) RETURNS INTEGER DECLARE Flag : BOOLEAN DECLARE Mid : INTEGER Flag ← -2 WHILE Flag <> -1 Mid ← LowerBound + ((UpperBound – LowerBound) DIV 2) IF UpperBound < LowerBound THEN RETURN -1 ELSE IF ThisArray[Mid] > SearchItem THEN UpperBound ← Mid – 1 ELSE IF ThisArray[Mid] < SearchItem THEN LowerBound ← Mid + 1 ELSE RETURN Mid ENDIF ENDIF ENDIF ENDWHILE ENDFUNCTION 6 Question Answer Marks 4(a) 1 mark per clause teacher(fred) busy(fred, tuesday, 1) 2

Mark scheme, page 9

9608/41 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2021 © UCLES 2021 Page 9 of 19 Question Answer Marks 4(b) 1 mark for 1 correct 1 mark for all 3 days of the week correct busy(jill, monday, 1) busy(jill, tuesday, 1) busy(jill, wednesday, 1) 1 mark for 1 correct 1 for the other 2 with OR busy(jill, monday, 1) OR busy(jill, tuesday, 1) OR busy(jill, wednesday, 1) 2 4(c) 1 mark busy(X, monday, 3) 1 4(d) 1 mark per bullet point • Checking X is a teacher • Checking Y is a timeslot, Z is a day • NOT(busy(X, Z, Y)) • All included, linked with ANDs and nothing superfluous teacher(X) AND timeslot(Y) AND day(Z) AND NOT(busy(X, Z, Y)) 4

Mark scheme, page 10

9608/41 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2021 © UCLES 2021 Page 10 of 19 Question Answer Marks 5(a) 1 mark per bullet point • Output = 21 • Function calls with Recursion(104,102) and Recursion(103, 102) • Function calls with 102 and 102, and 92 and 102 • Unwinding the return values 5+5+10+1 Function call A B Return value Recursion(104, 102) 104 102 5 + Recursion(103, 102) 5 + 16 Recursion(103, 102) 103 102 5 + Recursion(102, 102) 5 + 11 Recursion(102, 102) 102 102 10 + Recursion(92, 102) 10 + 1 Recursion(92, 102) 92 102 1 4

Mark scheme, page 11

9608/41 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2021 © UCLES 2021 Page 11 of 19 Question Answer Marks 5(b) 1 mark per bullet point to max 4 • Function header takes two parameters, returns the calculated value accurately (outside/end loop and in all cases) • Initialising variable to 1 outside loop (or adds 1 before returning) • Looping while A > 100 // looping until A <= 100 (or equivalent) … • … checking if A > B inside loop and if true, add 5 to variable and decrement A • … checking if A<= B in loop and if true, add 10 to variable and A – 10 Example pseudocode: FUNCTION Recursion(A, B : INTEGER) RETURNS INTEGER DECLARE Value : INTEGER Value ← 1 WHILE A > 100 IF A > B THEN Value ← Value + 5 A ← A - 1 ELSE Value ← Value + 10 A ← A - 10 ENDIF ENDWHILE RETURN Value ENDFUNCTION 4 Question Answer Marks 6(a)(i) 1 mark per bullet point • Data structure to store multiple pieces of data (under one identifier) • ... (stores data) of that can be different data types 2

Mark scheme, page 12

9608/41 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2021 © UCLES 2021 Page 12 of 19 Question Answer Marks 6(a)(ii) 1 mark per bullet point • record declaration named CustomerData … • … all 3 correct data items with suitable data types (and identifiers) TYPE CustomerData DECLARE CustomerID : INTEGER DECLARE FirstName : STRING DECLARE SecondName : STRING ENDTYPE 2 6(b) 1 mark per completed statement PROCEDURE StoreRecord(NewData : CustomerData) HashValue ← CustomerHash(NewData.CustomerID) Filename ← "CustomerRecords.dat" OPENFILE Filename FOR RANDOM SEEK Filename, HashValue PUTRECORD Filename, NewData CLOSE Filename ENDPROCEDURE 5 6(c) 1 mark for naming a feature, 1 for description. Max 2 for each feature Example: • Breakpoint • Stop the program at a set point and check the variables • Stepping/step-through etc. • Execute the program one line at a time to check the values • Variable watch window • Displays the variable values whilst the program is running so Kobi can make sure they are changed correctly 4

Mark scheme, page 13

9608/41 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2021 © UCLES 2021 Page 13 of 19 Question Answer Marks 6(d) 1 mark for benefit, 1 for drawback Benefit Example: • Saves time because does not have to write own code // write program faster • Programmer can have limited skills and still produce complex programs Drawback Example: • May not perform the tasks exactly as required • Solution is likely to be inefficient • Might produce errors • The programmer may not understand the solution and hence cannot edit/change 2 Question Answer Marks 7(a) 1 mark per bullet point to max 2 • To stop the program crashing … • To stop a run-time error … • … to make sure the input is the correct data type // other reasonable example 2

Mark scheme, page 14

9608/41 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2021 © UCLES 2021 Page 14 of 19 Question Answer Marks 7(b) 1 mark per bullet point • Using try (and close where appropriate) followed by the input • Catching exception • Outputting appropriate message (built-in or otherwise) Example program code: VB.NET Try Dim Value As Integer Console.WriteLine("Enter a number") Value = Console.ReadLine() Catch ex As Exception Console.WriteLine(ex.Message) End Try Python try: Value = int(input("Enter a number")) except: print("Invalid number") Pascal: begin try readln(Value); except On E : Exception do writeln("Invalid number"); end; 3 7(c) 1 mark per example • Check file exists • No input • No data in file • Array out of bounds • Calculation / division by 0 2

Mark scheme, page 15

9608/41 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2021 © UCLES 2021 Page 15 of 19 Question Answer Marks 8(a) 1 mark for rows with index 0, 1 and 3 1 mark for null pointers set to −1 Index LeftPointer Data RightPointer RootNode 0 [0] 3 50 1 [1] 6 67 2 [2] –1 77 –1 [3] 4 35 5 [4] –1 2 –1 [5] –1 43 –1 [6] –1 52 –1 [7] –1 –1 [8] –1 –1 [9] –1 –1 [10] –1 –1 2

Mark scheme, page 16

9608/41 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2021 © UCLES 2021 Page 16 of 19 Question Answer Marks 8(b) 1 mark for each completed statement PROCEDURE PostOrder(RootNode : INTEGER) IF BinaryTree[RootNode, 0] <> -1 THEN PostOrder(BinaryTree[RootNode, 0]) ENDIF IF BinaryTree[RootNode, 2] <> -1 THEN PostOrder(BinaryTree[RootNode, 2]) ENDIF OUTPUT(BinaryTree[RootNode, 1]) ENDPROCEDURE 5 Question Answer Marks 9(a) 1 mark per bullet point • array named StoredData of type integer • with 10 000 elements, index 0 – 9999 • All elements initialised with −1 Example pseudocode DECLARE StoredData : ARRAY[0:9999] OF INTEGER FOR X ← 0 to 9999 StoredData[X] ← -1 NEXT X 3 9(b) 1 mark per bullet point to max 7 7

Mark scheme, page 17

9608/41 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2021 © UCLES 2021 Page 17 of 19 Question Answer Marks 9(b) • Function declaration (and end where appropriate) taking data as (integer) parameter (returns Boolean) • Calculate hash: parameter mod 1000 + 6 • Check if StoredData[hashed value] = –1 … • … if it is –1, store data at hash … • … and return true • … if not –1, increment/decrement hashed value by 1 … • … if reached index 9999 return to index 0 // checking and going to 9999 if not at 0 • … repeatedly decrement until either found or all elements checked … • … returning False if full and True when stored Example program code VB.NET Function AddItem(DataToAdd) Dim Location As Integer Dim Found As Boolean Dim Counter As Integer Location = (DataToAdd Mod 1000) + 6 If StoredData(Location) <> -1 Then Found = False Counter = 0 While Found = False And Counter < 9999 Location = Location + 1 If Location > 9999 Then Location = 0 End If If StoredData(Location) = -1 Then Found = True End If Counter = Counter + 1 End While

Mark scheme, page 18

9608/41 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2021 © UCLES 2021 Page 18 of 19 Question Answer Marks 9(b) If Found = True Then StoredData(Location) = DataToAdd Return True Else Return False End If Else StoredData(Location) = DataToAdd Return True End If End Function Python def AddItem(DataToAdd): Location = (DataToAdd % 1000) + 6 if StoredData[Location] <> -1: Found = False Counter = 0 while Found == False and Counter < 9999: Location = Location + 1 if Location > 9999: Location = 0 if StoredData[Location] == -1: Found = True Counter = Counter + 1 if Found == True: StoredData[Location] = DataToAdd return True else: return False else: StoredData[Location] = DataToAdd return True

Mark scheme, page 19

9608/41 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2021 © UCLES 2021 Page 19 of 19 Question Answer Marks 9(b) Pascal function AddItem(DataToAdd:Integer):Boolean; begin Location := (DataToAdd mod 1000) + 6; if StoredData[Location] <> -1 then begin Found := false; Counter := 0; while (Found = false) and (Counter < 9999) do begin Location := Location + 1; if Location > 9999 then Location := 0; if StoredData[Location] = -1 then found := true; Counter := Counter + 1; end; if Found = true then begin StoredData[Location] := DataToAdd; AddItem := True; end Else begin AddItem := False; end; end else begin StoredData[Location] := DataToAdd; AddItem := True; end; end;

What you needed in this session

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

A50/75
B42/75
C35/75
D28/75
E21/75