Cambridge A Level Computer Science 9608 — 2021 May/June Paper 4 · Variant 2
9608/42/M/J/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.
Question paper20 pages




















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




















Paper as text
Question paper, page 1
Cambridge International AS & A Level This document has 20 pages. Any blank pages are indicated. DC (DH) 198992/5 © UCLES 2021 [Turn over * 7 1 4 2 1 0 9 8 0 4 * COMPUTER SCIENCE 9608/42 Paper 4 Further Problem-solving and Programming Skills May/June 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.
Question paper, page 2
2 9608/42/M/J/21 © UCLES 2021 1 An ordered binary tree stores the following data: Horse Donkey Kangaroo Cat Elephant (a) Identify the data in the root node of the binary tree. … [1] (b) Identify the data in one leaf node from the binary tree. … [1] (c) Complete the binary tree by adding the following data in the order given: Fish Iguana Rabbit Jaguar Kangaroo Horse Donkey Cat Elephant [2]
Question paper, page 3
3 9608/42/M/J/21 © UCLES 2021 [Turn over (d) Explain how an algorithm will search the binary tree to find Elephant. … … … … … [2]
Question paper, page 4
4 9608/42/M/J/21 © UCLES 2021 2 A company stores bookings in a random file. For each booking, the booking ID, customer ID, item ID and quantity are stored. These four values are all integers. (a) Write the pseudocode record declaration for the data type Booking. … … … … … … … [2]
Question paper, page 5
5 9608/42/M/J/21 © UCLES 2021 [Turn over (b) Each booking ID is a value between 100 000 and 999 999 inclusive. The hash value is calculated by dividing the booking ID by 100 000 and adding 3 to the remainder. (i) The function Hash() takes the booking ID as a parameter, calculates and returns the hash value. Write program code for the function Hash(). Programming language … Program code … … … … … [2] (ii) Calculate the hash value for each booking ID in the table. Booking ID Hash value 5 012 345 8 212 350 [1]
Question paper, page 6
6 9608/42/M/J/21 © UCLES 2021 (c) The function StoreBooking() takes a record as a parameter and stores it in the random file TheBookings.dat. The function uses Hash() to calculate the hash value for that record. The record is only stored if the value at the hashed value is NULL. FALSE is returned if there is already a record in that location and TRUE otherwise. You can assume that the file exists. Write pseudocode for the function StoreBooking(). … … … … … … … … … … … … … … … … … … … … … … … [7]
Question paper, page 7
7 9608/42/M/J/21 © UCLES 2021 [Turn over (d) Explain how exception handling can be used when reading from a file. … … … … [2]
Question paper, page 8
8 9608/42/M/J/21 © UCLES 2021 3 Ejaz is creating a program that will allow the user to create quizzes. He is using object-oriented programming (OOP). There are two classes: QuestionClass and QuizClass. The class attributes and methods are in the following tables. All attributes are declared as private. QuestionClass Question : STRING Answer : STRING Difficulty : INTEGER // stores the question // stores the correct answer // stores the difficulty as an integer // from 0(easy) to 10(hard) Constructor(QuestionP, AnswerP, DifficultyP) GetQuestion() GetDifficulty() GetAnswer() // creates an instance of QuestionClass // sets the attributes to the parameter // values // returns the question // returns the difficulty level // returns the answer QuizClass Questions : ARRAY[0:19] OF QuestionClass NumberOfQuestions : INTEGER // stores maximum 20 questions of // type QuestionClass // stores the number of questions // in this quiz Constructor() AddQuestion() GetQuestion() CheckAnswer() // creates an instance of // QuizClass // initialises NumberOfQuestions // to 0 // adds the parameter question to // the array // increments NumberOfQuestions // returns the next question to be // asked // takes an answer as a parameter // and returns TRUE if correct
Question paper, page 9
9 9608/42/M/J/21 © UCLES 2021 [Turn over (a) Write program code to define the class QuizClass. You are only required to write code for the attribute declarations and constructor. If you are writing in Python, include attribute declarations using comments. Use your programming language’s constructor method. Programming language … Program code … … … … … … … … [4]
Question paper, page 10
10 9608/42/M/J/21 © UCLES 2021 (b) The QuizClass method AddQuestion() takes a question object as a parameter and stores it in the next available location in the array Questions. It returns TRUE if it is successfully stored, and FALSE otherwise. Write program code for the method AddQuestion(). Programming language … Program code … … … … … … … … … … … … [4] (c) The first quiz is created with the identifier FirstQuiz. The first question in this quiz is: “What is 100 / 5 ?”. The answer is “20” and the difficulty level is 1. Write program code to: • declare an instance of QuizClass with the identifier FirstQuiz • declare an instance of QuestionClass with the identifier Question1 • add Question1 to the array in FirstQuiz using AddQuestion(). Programming language … Program code … … …
Question paper, page 11
11 9608/42/M/J/21 © UCLES 2021 [Turn over … … … … … … [5] (d) The object FirstQuiz contains objects of type QuestionClass. State the name of this OOP feature. … … [1] (e) Ejaz can use an interpreter and a compiler to translate program code during the development process. The program will be distributed without any access to the source code. (i) State when Ejaz should use an interpreter and a compiler. Each answer must be different. Interpreter … … Compiler … … [2] (ii) Give the name of two facilities that Ejaz can use to debug his program. 1 … … 2 … … [2] (iii) Describe one feature of an editor that Ejaz can use when writing the program. … … … … [2]
Question paper, page 12
12 9608/42/M/J/21 © UCLES 2021 4 Zara is writing a program to simulate a circular queue. The queue, MyNumbers, has 10 elements. Enqueue() takes a parameter value and stores it at the tail of the queue. Dequeue()returns the item at the head of the queue. The current state of the circular queue is: Index 0 1 2 3 4 5 6 7 8 9 Data 31 45 89 500 23 2 HeadIndex: 2 TailIndex: 8 (a) Show the state of the queue, HeadIndex and TailIndex after the following operations: Enqueue(23) Enqueue(100) Dequeue() Dequeue() Enqueue(50) Index 0 1 2 3 4 5 6 7 8 9 Data HeadIndex: …………………………… TailIndex: …………………………… [3]
Question paper, page 13
13 9608/42/M/J/21 © UCLES 2021 [Turn over (b) The global array, MyNumbers, is used to store the positive integer numbers for the queue. The following global variables are used: • HeadIndex stores the index of the first element in the queue • TailIndex stores the index of the next free space in the queue • NumberInQueue stores the number of items in the queue. (i) The function Enqueue() takes the value to be added to the queue as a parameter. The function returns TRUE if the item was added, or FALSE if the queue is full. Complete the pseudocode for the function Enqueue(). FUNCTION Enqueue(BYVALUE DataToInsert : INTEGER) RETURNS BOOLEAN IF NumberInQueue > … THEN RETURN FALSE ELSE MyNumbers[…] … TailIndex … IF TailIndex > 9 THEN TailIndex … ENDIF NumberInQueue NumberInQueue + 1 RETURN TRUE ENDIF ENDFUNCTION [5]
Question paper, page 14
14 9608/42/M/J/21 © UCLES 2021 (ii) The function Dequeue() returns the value at the head of the queue, or −1 if the queue is empty. Complete the pseudocode for the function Dequeue(). FUNCTION Dequeue() RETURNS INTEGER … … … … … … … … … … … … … … … … … ENDFUNCTION [5]
Question paper, page 15
15 9608/42/M/J/21 © UCLES 2021 [Turn over 5 The following procedure performs an insertion sort on the global array TheArray that has 10 elements. Complete the pseudocode for the procedure InsertionSort(). PROCEDURE InsertionSort() DECLARE Count : INTEGER DECLARE Counter : INTEGER DECLARE Temp : INTEGER Count … WHILE Count < 10 Temp TheArray[Count] Counter Count … WHILE … >= 0 AND TheArray[Counter] > … TheArray[Counter + 1] TheArray[Counter] Counter Counter - 1 ENDWHILE TheArray[…] Temp Count Count + 1 ENDWHILE ENDPROCEDURE [5]
Question paper, page 16
16 9608/42/M/J/21 © UCLES 2021 6 A social networking website only allows people who are over 16 years old to join. To create an account, the user must enter: • their age • a unique username, which is compared to others in the database • a password that must be at least 8 characters long, with at least one upper case letter, one lower case letter, one symbol and one digit. If the user is not old enough to join the network, the statement “Too young” is displayed. If the user is old enough, but the username is already taken, the statement “Choose another username” is displayed. If the user is old enough, but the password does not meet the requirements, the statement “Password does not meet requirements” is displayed. (a) Complete the decision table for the social networking website. Conditions Available username N Y N Y N Y N Y Suitable password N N Y Y N N Y Y Age > 16 N N N N Y Y Y Y Actions “Too young” “Choose another username” “Password does not meet requirements” [4] (b) Simplify the decision table by removing the redundancies. Conditions Available username Suitable password Age > 16 Actions “Too young” “Choose another username” “Password does not meet requirements” [3]
Question paper, page 17
17 9608/42/M/J/21 © UCLES 2021 [Turn over 7 Anika is designing a computer game. The user controls a character that moves around a virtual world. When the character meets an animal: • if the animal’s strength is less than 10, the animal runs away • if the animal’s health is less than 10, it is caught by the character • if the animal’s strength and health are both 10 or more, the character and the animal compete. When the character and animal compete, the animal’s health, animal’s strength and character’s health are decreased by 1. This is repeated until one of the following conditions is met: • the character’s health goes to 0, the game is over • the animal’s strength goes below 10, the animal runs away • the animal’s health goes below 10, the animal is caught. Complete the state-transition diagram for this part of the program. animal health < 10 animal strength < 10 animal health < 10 animal strength < 10 animal health = animal health − 1 animal strength = animal strength − 1 … … … … … … … … … Compete Meet animal … … Game over [5]
Question paper, page 18
18 9608/42/M/J/21 © UCLES 2021 8 The table shows assembly language instructions for a processor that has one general purpose register, the Accumulator (ACC), and an Index Register (IX). Instruction Explanation Label Op code Operand LDM #n Immediate addressing. Load the number n to ACC LDD <address> Direct addressing. Load the contents of the location at the given address to ACC LDX <address> Indexed addressing. Form the address from <address> + the contents of the Index Register. Copy the contents of this calculated address to ACC LDR #n Immediate addressing. Load the number n to IX STO <address> Store the contents of ACC at the given address ADD <address> Add the contents of the given address to ACC INC <register> Add 1 to the contents of the register (ACC or IX) CMP #n Compare the contents of ACC with number n JPN <address> Following a compare instruction, jump to <address> if the compare was False LSL #n Bits in ACC are shifted n places to the left. Zeroes are introduced on the right hand end LSR #n Bits in ACC are shifted n places to the right. Zeroes are introduced on the left hand end OUT Output to the screen the character whose ASCII value is stored in ACC END Return control to the operating system <label>: <op code> <operand> Labels an instruction <label>: <data> Gives a symbolic address <label> to the memory location with contents <data>
Question paper, page 19
19 9608/42/M/J/21 © UCLES 2021 An algorithm stores a 3-character word. It takes each character in turn, multiplies its value by 2 and outputs the new character. Complete the following assembly language program for the algorithm using the instruction set provided on the previous page. Instruction Comment Label Op code Operand // initialise Index Register to 0 LDX character // load character and multiply by 2 OUT // output the new character INC IX // increment the Index Register LDD count // loop 3 times STO count CMP #3 LOOP END // end program count: 0 character: B01000001 // the 3-character stored word B10001110 B01000100 [5]
Question paper, page 20
20 9608/42/M/J/21 © UCLES 2021 BLANK 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.
Mark scheme, page 1
This document consists of 20 printed pages. © UCLES 2021 [Turn over Cambridge International AS & A Level COMPUTER SCIENCE 9608/42 Paper 4 Further Problem-solving and Programming Skills May/June 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 May/June 2021 series for most Cambridge IGCSE™, Cambridge International A and 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 2021 © UCLES 2021 Page 2 of 20 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 2021 © UCLES 2021 Page 3 of 20 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 2021 © UCLES 2021 Page 4 of 20 Question Answer Marks 1(a) Horse 1 1(b) Cat // Elephant // Kangaroo 1 1(c) 1 mark for Iguana and Jaguar in the correct place 1 mark for Rabbit and Fish in the correct place 2 1(d) 1 mark per bullet point. Mark in pairs. • (Compare Elephant to horse) Elephant/E is less than Horse/H so check/go left … • … (Compare to Elephant to Donkey) Elephant/E is greater than Donkey/D so check/go right (Elephant found) or • Check if Elephant/E is less than or greater than root node … • … check subtree/follow pointer to next node to left/right recursively until found or leaf 2 Horse Donkey Cat Elephant Fish Kangaroo Iguana Jaguar Rabbit
Mark scheme, page 5
9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2021 © UCLES 2021 Page 5 of 20 Question Answer Marks 2(a) 1 mark each: • booking record declaration (and end) … • … defining all 4 fields with integer data types TYPE Booking DECLARE BookingID : INTEGER DECLARE CustomerID : INTEGER DECLARE ItemID : INTEGER DECLARE Quantity : INTEGER ENDTYPE 2 2(b)(i) 1 mark per bullet point • Function header and close taking a booking ID as parameter AND return the calculated value • Calculating hash value correctly using parameter Example code VB.NET Function Hash(BookingID) Hash = BookingID Mod 100000 + 3 End Function Python def Hash(BookingID): HashV = BookingID % 100000 + 3 return HashV Python alternative: MOD(BookingID, 1000000) + 3 Pascal Function Hash(BookingID:Integer):Integer begin Hash := BookingID MOD 100000 + 3 end; 2
Mark scheme, page 6
9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2021 © UCLES 2021 Page 6 of 20 Question Answer Marks 2(b)(ii) 1 mark for both correct hash values Booking ID Hash value 5012345 12348 8212350 12353 1
Mark scheme, page 7
9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2021 © UCLES 2021 Page 7 of 20 Question Answer Marks 2(c) 1 mark per bullet point to max 7 • Function heading, taking a booking record as parameter • Use Hash() to calculate hash with Booking ID of the parameter • … storing/using return value from Hash() • Open "TheBookings.dat" for random access • Go to location of returned hash value • Check if there is already a record present … • … if empty, put the record in the location and return TRUE • … otherwise return FALSE and do not store the • Close the opened file in all circumstances Example pseudocode FUNCTION StoreBooking(BookingRecord : Booking) RETURNS Boolean RecordLocation ← Hash(BookingRecord.BookingID) Filename ← "TheBookings.dat" OPENFILE Filename FOR RANDOM SEEK Filename, RecordLocation GETRECORD Filename, RecordData IF RecordData = NULL THEN PUTRECORD Filename, BookingRecord CLOSE Filename RETURN True ELSE CLOSE Filename RETURN False ENDIF ENDFUNCTION 7
Mark scheme, page 8
9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2021 © UCLES 2021 Page 8 of 20 Question Answer Marks 2(d) 1 mark per bullet point to max 2 e.g. • Catch if the file does not exist // Catch wrong path … • Catch if at end of file // check if no data in file … • Check if file is already open … • … so the program does not crash • … output an appropriate message • … so null data is not accessed 2
Mark scheme, page 9
9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2021 © UCLES 2021 Page 9 of 20 Question Answer Marks 3(a) 1 mark per bullet point max 4 • Class QuizClass header (and end where appropriate) • Constructor header (and end where appropriate) Ignore any parameters • Private questions array of size 20, of type QuestionClass • Private attribute NumberOfQuestions as type integer and initialising to 0 in constructor Example code VB.NET Class QuizClass Private Questions(19) As QuestionClass Private NumberOfQuestions As Integer Public Sub New() NumberOfQuestions = 0 End Sub End Class Python class QuizClass(): #Private Questions[20] self.__QuestionClass #Private self.__NumberOfQuestions Integer def __init__(self): self.__NumberOfQuestions = 0 4
Mark scheme, page 10
9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2021 © UCLES 2021 Page 10 of 20 Question Answer Marks 3(a) Pascal type QuizClass = class private NumberOfQuestions: Integer; Questions : array[0..19] of QuestionClass; public Constructor init(); end; Constructor QuizClass.init(); begin NumberOfQuestions := 0; end;
Mark scheme, page 11
9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2021 © UCLES 2021 Page 11 of 20 Question Answer Marks 3(b) 1 mark per bullet point to max 4 • Function header and close, taking parameter of type QuestionClass if data type given • Checking if array is full … • …returning FALSE if it is full • (otherwise) store object in next position in array // append to array… • …increment NumberOfQuestions and return TRUE Example code VB.NET Public Function AddQuestion(QuestionObject) If NumberOfQuestions < 20 Then Questions(NumberOfQuestions) = QuestionObject NumberOfQuestions = NumberOfQuestions + 1 return True Else return False End If End Function Python def AddQuestion(self, QuestionObject): if self.__NumberOfQuestions < 20: self.__Questions[self.__NumberOfQuestions] = QuestionObject self.__NumberOfQuestions = self.__NumberOfQuestions + 1 return True else: return False 4
Mark scheme, page 12
9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2021 © UCLES 2021 Page 12 of 20 Question Answer Marks 3(b) Pascal Function AddQuestion(QuestionObject:QuestionClass):Boolean; begin if NumberOfQuestions < 20 then Questions[NumberOfQuestions] := QuestionObject; NumberOfQuestions := NumberOfQuestions + 1; return True; else return False; end; 3(c) 1 mark per bullet • Instance of QuizClass … • … with no parameters with identifier FirstQuiz • Instance of QuestionClass … • … with correct parameters and identifier Question1 • Question added to FirstQuiz using function AddQuestion Example code VB.NET (Does not require New keyword) Dim FirstQuiz As QuizClass = New QuizClass() Dim Question1 As QuestionClass = New QuestionClass("What is 100/5?", "20", 1) FirstQuiz.AddQuestion(Question1) Python FirstQuiz = QuizClass() Question1 = QuestionClass("What is 100/5?", "20", 1) FirstQuiz.AddQuestion(Question1) Pascal FirstQuiz := QuizClass.Create(); Question1 := QuestionClass.Create("What is 100/5?", "20", 1); FirstQuiz.AddQuestion(Question1); 5 3(d) Containment 1
Mark scheme, page 13
9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2021 © UCLES 2021 Page 13 of 20 Question Answer Marks 3(e)(i) 1 mark for interpreter, 1 mark for compiler Interpreter: • Writing the code // debugging // when testing for errors Compiler: • Program is complete // program needs distributing // program is bug-free // user acceptance stage // beta testing stage // writing the program // when debugging 2 3(e)(ii) 1 mark for each suitable facility to max 2 e.g. • Break-point • Stepping // step over // step through • (Variable/expression) watch window 2
Mark scheme, page 14
9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2021 © UCLES 2021 Page 14 of 20 Question Answer Marks 3(e)(iii) 1 mark per bullet point to max 2. Mark in pairs/groups. e.g. • Pretty print // colour coding • Colours key words in different colours • So you can see where there are errors • Syntax error highlighting // Dynamic syntax check • Highlights/underlines syntax errors • So you can correct them as you program • Auto-complete • automatically adds closing statements • Saves the user typing these terms • Context sensitive prompts • Displays possible code for the user to select from • So they do not make mistakes • Auto-indent • Moves the code to the correct location • So that it is easier to read • So that the correct code is inside each construct • Auto-correct • Changes spelling mistakes • To reduce syntax errors • Collapse/expand modules • Allows you to hide sections of code • To make it easier to read the code you are focused on 2
Mark scheme, page 15
9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2021 © UCLES 2021 Page 15 of 20 Question Answer Marks 4(a) 1 mark for correct items in the queue 1 mark for correct HeadIndex 1 mark for TailIndex 0 1 2 3 4 5 6 7 8 9 50 89 500 23 2 23 100 HeadIndex: 4 TailIndex: 1 3 4(b)(i) 1 mark for each completed statement (in bold) FUNCTION Enqueue(BYVAL DataToInsert : INTEGER) RETURNS BOOLEAN IF NumberInQueue > 9 // = 10 THEN RETURN False ELSE MyNumbers[TailIndex] ← DataToInsert TailIndex ← TailIndex + 1 IF TailIndex > 9 THEN TailIndex ← 0 ENDIF NumberInQueue ← NumberInQueue + 1 RETURN True ENDIF ENDFUNCTION 5
Mark scheme, page 16
9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2021 © UCLES 2021 Page 16 of 20 Question Answer Marks 4(b)(ii) 1 mark per bullet point max 5 • Checking if queue is empty/full … • …and returning −1 if empty (Otherwise) • Incrementing HeadIndex … • …catching if it goes above 9 and setting to 0 • Decrement NumberInQueue • returning first element Example pseudocode FUNCTION Dequeue() RETURNS INTEGER DECLARE ItemToReturn : INTEGER IF NumberInQueue = 0 THEN ItemToReturn ← -1 ELSE ItemToReturn ← MyNumbers(HeadIndex) IF HeadIndex = 9 THEN HeadIndex ← 0 ELSE HeadIndex ← HeadIndex + 1 ENDIF NumberInQueue ← NumberInQueue - 1 ENDIF RETURN ItemToReturn ENDFUNCTION 5
Mark scheme, page 17
9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2021 © UCLES 2021 Page 17 of 20 Question Answer Marks 5 1 mark for each completed statement (in bold) PROCEDURE InsertionSort() DECLARE Count : INTEGER DECLARE Counter : INTEGER DECLARE Temp : INTEGER Count ← 1 WHILE Count < 10 Temp = TheArray[Count] Counter = Count - 1 WHILE Counter >= 0 AND TheArray[Counter] > Temp TheArray[Counter + 1] ← TheArray[Counter] Counter ← Counter - 1 ENDWHILE TheArray[Counter + 1] ← Temp Count ← Count + 1 ENDWHILE ENDPROCEDURE 5
Mark scheme, page 18
9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2021 © UCLES 2021 Page 18 of 20 Question Answer Marks 6(a) 1 mark for each pair of columns/shaded area. Available username N Y N Y N Y N Y Suitable password N N Y Y N N Y Y Age > 16 N N N N Y Y Y Y "Too young" Y Y Y Y N N N N "Choose another username" N N N N Y N Y N "Password does not meet requirements" N N N N Y Y N N 4 6(b) 1 mark for each column Available username – N – Suitable password – – N Age > 16 N Y Y "Too young" Y N N "Choose another username" N Y N "Password does not meet requirements" N N Y 3
Mark scheme, page 19
9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2021 © UCLES 2021 Page 19 of 20 Question Answer Marks 7 1 mark for each complete statement 5 animal health = animal health ‒ 1 animal strength = animal strength ‒ 1 character health = character health ‒ 1 animal health < 10 Animal health >= 10 animal strength >=10 animal strength < 10 animal strength < 10 Animal runs away Animal caught Compete Meet animal animal health < 10 Character (Health) = 0 // <=0 // <1 Game over
Mark scheme, page 20
9608/42 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2021 © UCLES 2021 Page 20 of 20 Question Answer Marks 8 1 mark for each complete instruction, 1 mark for label LOOP Instruction Label Op code Operand LDR #0 LOOP LDX character LSL #1 OUT INC IX LDD count INC ACC STO count CMP #3 JPN LOOP END count: 0 Character: B01000001 B10001110 B01000100 5
What you needed in this session
Cambridge’s own grade thresholds for 2021 May/June, Paper 4 · Variant 2. A higher threshold means an easier paper — the bar moves with how the cohort did.