Cambridge A Level Computer Science 9608 — 2020 Oct/Nov Paper 2 · Variant 3
9608/23/O/N/20 · 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 scheme27 pages
Answers below. Sit the paper first if you are practising.



























Paper as text
Question paper, page 1
Cambridge International AS & A Level DC (JC/CT) 188579/4 © UCLES 2020 [Turn over This document has 16 pages. Blank pages are indicated. * 5 4 7 9 1 0 0 9 4 4 * COMPUTER SCIENCE 9608/23 Paper 2 Fundamental Problem-solving and Programming Skills October/November 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/23/O/N/20 © UCLES 2020 1 (a) A programmer uses the process of stepwise refinement to break down a problem. Explain the purpose of stepwise refinement. … … … … [2] (b) Programming languages support different data types. These usually include STRING and REAL. Complete the table by giving four other data types and an example data value for each. Data type Example data value [4] (c) An experienced programmer is working on a program that is written in a language she is not familiar with. (i) State one feature of the program that she should be able to recognise. … … [1] (ii) State the type of skill that would allow her to recognise this feature. … … [1] (d) Give three methods that may be used to identify and locate errors in a program after it has been written. You may include one feature found in a typical Integrated Development Environment (IDE). 1 … 2 … 3 … [3]
Question paper, page 3
3 9608/23/O/N/20 © UCLES 2020 [Turn over 2 (a) An algorithm is needed to input a list of numbers representing test marks for a class of 30 students. The algorithm will output the number of students who have a mark greater than 75. It will also output the average mark for the class. Document the algorithm using structured English. … … … … … … … … … … … … [8] (b) Each pseudocode statement in the following table contains an error. State the error in each case. Refer to the Appendix on page 16 for the list of built-in functions and operators. Statement Error Code LEFT(3, "Europe") Hour MID("ALARM:12:02", 7, 6) Size LENGTH(27.5) Num INT(27 / (Count + 3) Result "Conditional" AND "Loop" [5]
Question paper, page 4
4 9608/23/O/N/20 © UCLES 2020 (c) Part of a program flowchart is shown. LOOP Set Status to TopUp() Set Index to Index + 1 SetLevel("Super") Set Status to FALSE Set Index to 0 Is Status = TRUE ? Is Index > 100 ? NO NO YES YES Write program code to implement the flowchart shown. Variable declarations are not required. Programming language … Program code … … … … … … … … … … [6]
Question paper, page 5
5 9608/23/O/N/20 © UCLES 2020 [Turn over 3 A global 1D array, ProdNum, of type INTEGER contains 5 000 elements and is used to store product numbers. A procedure is needed to sort ProdNum into ascending order using a bubble sort algorithm. Write program code for the procedure BubbleSort(). 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 6
6 9608/23/O/N/20 © UCLES 2020 … … … [7] 4 (a) The following pseudocode includes a procedure that searches for a value in a 1D array and outputs each position in the array where the value is found. Refer to the Appendix on page 16 for the list of built-in functions and operators. DECLARE NameList : ARRAY [1:100] OF STRING DECLARE SearchString : STRING PROCEDURE Search() DECLARE Index : INTEGER FOR Index 1 TO 100 IF NameList[Index] = SearchString THEN OUTPUT "Found at " & NUM_TO_STRING(Index) ENDIF ENDFOR ENDPROCEDURE The specification of module Search() changes. The pseudocode needs to be amended to meet a new requirement. The procedure needs to be implemented as a function, Search(), which will: • take the search value as a parameter • return an integer which is: • either the index value where the search value is first found • or –1 if the search value is not found.
Question paper, page 7
7 9608/23/O/N/20 © UCLES 2020 [Turn over Write the pseudocode for the function Search(). … … … … … … … … … … … … … … … … … … … … … [6] (b) A change to the specification in part (a) required a modification of the algorithm. Give the term used for this type of modification. … [1] (c) A change to the specification is only one reason to modify an algorithm. Give another reason for the modification of an algorithm. … [1]
Question paper, page 8
8 9608/23/O/N/20 © UCLES 2020 (d) Consider the following pseudocode: 10 DECLARE VarA : INTEGER 11 VarA 20 12 13 CALL ProcA(VarA) 14 OUTPUT VarA // first value output 15 16 CALL ProcB(VarA) 17 OUTPUT VarA // second value output 18 19 20 PROCEDURE ProcA(BYVALUE ThisValue : INTEGER) 21 ThisValue ThisValue + 5 22 ENDPROCEDURE 23 24 PROCEDURE ProcB(BYREF ThisValue : INTEGER) 25 ThisValue ThisValue + 5 26 ENDPROCEDURE Procedures ProcA() and ProcB() use two methods of passing parameters. Complete the following table. Output Explanation First value (line 14) … … … … Second value (line 17) … … … … [4]
Question paper, page 9
9 9608/23/O/N/20 © UCLES 2020 [Turn over (e) The procedures ProcA and ProcB in part (d) are examples of program modules. Give two advantages of using program modules in program design. 1 … … 2 … … [2]
Question paper, page 10
10 9608/23/O/N/20 © UCLES 2020 5 A hashtag is used on a social media network to make it easier to find messages with a specific theme or content. A hashtag is a string consisting of a hash character ‘#’ followed by a number of alphanumeric characters. A message may contain several hashtag strings. A hashtag may be terminated by a space character, the start of the next hashtag, or by the end of the message. For example, the following message contains three hashtags: "#Alarm34 is the result of #BatteryFailure in the #PowerModule" The hashtags in this message are "#Alarm34", "#BatteryFailure" and "#PowerModule". A program is being developed to monitor their use. The program will include two global arrays each containing 10 000 elements: • A 1D array, TagString, of type STRING storing each hashtag in a single element of the array. All unused array elements contain an empty string (""). • A 1D array, TagCount, of type INTEGER storing a count of the number of times each hashtag is used. The count value in a given element relates to the hashtag value stored in the element in the TagString array with the corresponding index value. A developer has started to define the modules. Module GetStart() has already been written. Module Description GetStart() • Called with two parameters: • a message of type STRING • an integer giving the number of the required hashtag; for example, GetStart(Message, 3) would search for the third hashtag in the string Message • Returns an integer value representing the start position of the hashtag in the message, or value −1 if that hashtag does not exist AddHashtag() • Called with a hashtag of type STRING • Copies the hashtag to the next free element of the TagString array, and sets the corresponding element of the TagCount array to 1 • Returns FALSE if there are no unused elements in the TagString array, otherwise returns TRUE CountHashtag() • Called with a message of type STRING • Searches the message for hashtags using GetStart() • Returns a value representing the number of hashtags in the message IncrementHashtag() • Called with a hashtag of type STRING • Increments the value of the appropriate element in the TagCount array if the hashtag is found • Returns TRUE if the hashtag is found, or FALSE if the hashtag is not found
Question paper, page 11
11 9608/23/O/N/20 © UCLES 2020 [Turn over (a) Write pseudocode for the module AddHashtag(). … … … … … … … … … … … … … … … … … … … … … … … … … … … [6]
Question paper, page 12
12 9608/23/O/N/20 © UCLES 2020 (b) Write program code for the module CountHashtag(). The module description is repeated here for reference. Module Description CountHashtag() • Called with a message of type STRING • Searches the message for hashtags using GetStart() • Returns a value representing the number of hashtags in the message 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 … … … … … … … … … … … … … … … … … … … … … [6]
Question paper, page 13
13 9608/23/O/N/20 © UCLES 2020 [Turn over (c) Write program code for the module IncrementHashtag(). The module description is repeated here for reference. Module Description IncrementHashtag() • Called with a hashtag of type STRING • Increments the value of the appropriate element in the TagCount array if the hashtag is found • Returns TRUE if the hashtag is found, or FALSE if the hashtag is not found 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 … … … … … … … … … … … … … … … … … … … [4]
Question paper, page 14
14 9608/23/O/N/20 © UCLES 2020 (d) A procedure, OutputMostPop(), is needed to output the most popular hashtag. The most popular hashtag is the one with the highest count value stored in the TagCount array. As a reminder, the program includes two global arrays each containing 10 000 elements: • A 1D array, TagString, of type STRING storing each hashtag in a single element of the array. All unused array elements contain an empty string (""). • A 1D array, TagCount, of type INTEGER storing a count of the number of times each hashtag is used. The count value in a given element relates to the hashtag value stored in the element in the TagString array with the corresponding index value. If the maximum count value occurs once, the procedure will output the corresponding hashtag and the count value. It is possible for more than one hashtag to have the same highest count value. In this case, the procedure will output the maximum count value together with the number of hashtags with this maximum count value. In both cases, the procedure must also output a suitable message. You can assume that the arrays contain data for at least one hashtag. Write pseudocode for the OutputMostPop() procedure. … … … … … … … … … … … … … … … … …
Question paper, page 15
15 9608/23/O/N/20 © UCLES 2020 [Turn over … … … … … … … … … … … … … … … … … … … … … … … … … … … … … [8]
Question paper, page 16
16 9608/23/O/N/20 © UCLES 2020 Appendix Built-in functions (pseudocode) Each function returns an error if the function call is not properly formed. LENGTH(ThisString : STRING) RETURNS INTEGER returns the integer value representing the length of string 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 string "ABC" RIGHT(ThisString: STRING, x : INTEGER) RETURNS STRING returns rightmost x characters from ThisString Example: RIGHT("ABCDEFGH", 3) returns string "FGH" 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 string "BCD" INT(x : REAL) RETURNS INTEGER returns the integer part of x Example: INT(27.5415) returns 27 NUM_TO_STRING(x : REAL) RETURNS STRING returns a string representation of a numeric value. Note: This function will also work if x is of type INTEGER Example: NUM_TO_STRING(87.5) returns "87.5" 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 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 27 printed pages. © UCLES 2020 [Turn over Cambridge International AS & A Level COMPUTER SCIENCE 9608/23 Paper 2 Written Paper October/November 2020 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 2020 series for most Cambridge IGCSE™, Cambridge International A and AS Level and Cambridge Pre-U components, and some Cambridge O Level components.
Mark scheme, page 2
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2020 © UCLES 2020 Page 2 of 27 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/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2020 © UCLES 2020 Page 3 of 27 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/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2020 © UCLES 2020 Page 4 of 27 Question Answer Marks 1(a) One mark per bullet point The purpose is: • to express the algorithm in a level of sufficient detail // to split a large task into (smaller) sub-tasks • so that it can be programmed // so that individual tasks are easier to solve // to make the problem more manageable / understandable 2 1(b) Many acceptable answers, must be four different data types together with appropriate values One mark per row For example: Data type Example data value BOOLEAN FALSE CHAR '!' DATE 01/01/01 INTEGER 27 Note: STRING and REAL are excluded as these are given in the question. 4 1(c)(i) Max 1 mark, features include: • Control Structures / selection statements / iteration statements / IO statements • Modular structure (functions, procedures) • Parameters to / from subroutines • Variable declaration / assignment /data structures / OOP ref 1
Mark scheme, page 5
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2020 © UCLES 2020 Page 5 of 27 Question Answer Marks 1(c)(ii) • Transferable skill 1 1(d) Max 3 marks, methods include: • IDE features: breakpoints / single stepping / watch window • Manually check program code / reading error report • Trace table / dry run / White-box testing • Use of appropriate test data • Addition of output statement to follow changes to variables 3 Question Answer Marks 2(a) One mark per step (or equivalent): 1 Set Total to 0 2 Set AGradeCount to 0 3 Input Mark 4 Add Mark to Total 5 If Mark > 75 then increment AGradeCount 6 Repeat from Step 3 for 30 times 7 Output AGradeCount 8 Output Total / 30 8
Mark scheme, page 6
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2020 © UCLES 2020 Page 6 of 27 Question Answer Marks 2(b) One mark per row: Statement Error Code ← LEFT(3, "Europe") Parameters are reversed Hour ← MID("ALARM:12:02", 7, 6) Third param too big (should be max 5) // string too short Size ← LENGTH(27.5) Invalid type – param should be a string Num ← INT(27/ (Count + 3) Missing closing bracket Result ← "Conditional" AND "Loop" Wrong variable types / operator 5
Mark scheme, page 7
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2020 © UCLES 2020 Page 7 of 27 Question Answer Marks 2(c) ‘Pseudocode’ solution included here for development and clarification of mark scheme. Programming language example solutions appear in the Appendix. Index ← 0 Status ← FALSE WHILE Status <> TRUE Status ← TopUp() Index ← Index + 1 ENDWHILE IF Index > 100 THEN SetLevel("Super") ENDIF Mark as follows: 1 Set Index to 0 and Status to FALSE 2 Pre-condition loop 3 Assign value of TopUp() to Status in a loop 4 Increment Index in a loop 5 Test Index greater than 100 after loop 6 If TRUE then Call to SetLevel with param "Super" 6
Mark scheme, page 8
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2020 © UCLES 2020 Page 8 of 27 Question Answer Marks 3(a) ‘Pseudocode’ solution included here for development and clarification of mark scheme. Programming language example solutions appear in the Appendix. PROCEDURE BubbleSort() DECLARE Temp : INTEGER DECLARE NoSwaps : BOOLEAN DECLARE Boundary, J : INTEGER Boundary ← 4999 REPEAT NoSwaps ← TRUE FOR J ← 1 TO Boundary IF ProdNum[J]> ProdNum[J+1] THEN Temp ← ProdNum[J] ProdNum[J] ← ProdNum[J+1] ProdNum[J+1] ← Temp NoSwaps ← FALSE ENDIF ENDFOR Boundary ← Boundary - 1 UNTIL NoSwaps = TRUE ENDPROCEDURE 7
Mark scheme, page 9
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2020 © UCLES 2020 Page 9 of 27 Question Answer Marks 3(a) Mark as follows, max 7 marks from 8 possible marks: 1 Procedure heading and ending 2 Conditional outer loop (may be count-controlled but if so must be >= 4999 iterations) 3 An inner loop 4 Correct range for inner loop 5 Comparison (element n with n + 1) in a loop 6 Swap array element in a loop 7 'No-Swap' mechanism: (both needed for mark): o Conditional outer loop including flag reset o Flag set in inner loop to indicate swap 8 Reducing Boundary in the outer loop
Mark scheme, page 10
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2020 © UCLES 2020 Page 10 of 27 Question Answer Marks 4(a) FUNCTION Search(SearchString : STRING) RETURNS INTEGER DECLARE RetVal : INTEGER DECLARE Index : INTEGER RetVal ← -1 Index ← 1 WHILE Index <= 100 AND RetVal = -1 IF NameList[Index] = SearchString THEN RetVal ← Index ENDIF Index ← Index + 1 ENDWHILE RETURN RetVal ENDFUNCTION Mark as follows: 1 Function heading and ending including parameter 2 Declaration of integer for Index 3 Initialisation and increment of Index (implied in FOR loop) 4 Conditional loop // FOR loop with immediate RETURN if SearchString found 5 Comparison of array element with SearchString AND assigning just the first occurrence to RetVal OR setting the termination condition 6 Return RetVal (correctly in both cases) 6
Mark scheme, page 11
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2020 © UCLES 2020 Page 11 of 27 Question Answer Marks 4(b) • Adaptive maintenance 1 4(c) Ma 1 mark, reasons include: • Program doesn’t perform as expected / does not meet the original specification • Program contains errors / bugs • Performance / efficiency needs improving • New hardware has been introduced 1 4(d) One mark for each value One mark for each explanation Output Explanation 20 A copy of the variable itself is passed 25 A pointer to / the address of the variable is passed 4 4(e) Max 2 marks, example answers: • Allows the module to be called from many / multiple places // re-used • Module code can be (independently) tested and debugged once and can then be used repeatedly • If the module task changes the change needs to be made only once • Reduces unnecessary code duplication • Allows modules to be shared among many programmers / given to programmers with specific skills • Makes the program easier to work on / debug / test / etc 2
Mark scheme, page 12
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2020 © UCLES 2020 Page 12 of 27 Question Answer Marks 5(a) FUNCTION AddHashtag (HashTag : STRING) RETURNS BOOLEAN DECLARE Index : INTEGER DECLARE Added : BOOLEAN CONSTANT EMPTY = "" Added ← FALSE Index ← 1 // first element REPEAT IF TagString[Index] = EMPTY THEN TagString[Index} ← HashTag TagCount[Index] ← 1 Added ← TRUE ELSE Index ← Index + 1 ENDIF UNTIL Index > 10000 OR Added = TRUE RETURN Added ENDFUNCTION 1 mark for each of the following: 1 Declaration of two local variables: Integer for index & Boolean for return value (unless immediate Return used) 2 Conditional loop through all elements until empty element found OR end of array 3 Test if TagString element is empty in a loop 4 If so then assign HashTag to TagString[] and 1 to TagCount[] 5 Set loop termination 6 Return Boolean (for both cases) 6
Mark scheme, page 13
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2020 © UCLES 2020 Page 13 of 27 Question Answer Marks 5(b) ‘Pseudocode’ solution included here for development and clarification of mark scheme. Programming language example solutions appear in the Appendix. FUNCTION CountHashtag (Message : STRING) RETURNS INTEGER DECLARE TagNum, StartPos : INTEGER DECLARE Found : BOOLEAN TagNum ← 0 Found ← TRUE REPEAT StartPos ← GetStart(Message, TagNum + 1) IF StartPos = -1 THEN Found ← FALSE ELSE TagNum ← TagNum + 1 ENDIF UNTIL NOT Found RETURN TagNum ENDFUNCTION 1 mark for each of the following: 1 Function heading and ending including parameter 2 Declaration and initialisation of local integer for count (TagNum) 3 Conditional loop through message 4 Use of GetStart() in a loop 5 Test GetStart() return value for -1 and increment count accordingly in a loop 6 Return integer value 6
Mark scheme, page 14
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2020 © UCLES 2020 Page 14 of 27 Question Answer Marks 5(c) ‘Pseudocode’ solution included here for development and clarification of mark scheme. Programming language example solutions appear in the Appendix. FUNCTION IncrementHashtag (HashTag : STRING) RETURNS BOOLEAN DECLARE Index : INTEGER DECLARE Found : BOOLEAN Found ← FALSE Index ← 1 // first element REPEAT IF TagString[Index] = HashTag THEN TagCount[Index] ← TagCount[Index] + 1 Found ← TRUE ELSE Index ← Index + 1 ENDIF UNTIL Index > 10000 OR Found = TRUE RETURN Found ENDFUNCTION 1 mark for each of the following: 1 Conditional loop until hashtag found or end of array 2 Compare element value to parameter in a loop 3 If found, increment corresponding TagCount element 4 Return Boolean correctly in both cases 4
Mark scheme, page 15
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2020 © UCLES 2020 Page 15 of 27 Question Answer Marks 5(d) PROCEDURE OutputMostPop() DECLARE Index : INTEGER DECLARE MostPopTag : STRING DECLARE Max : INTEGER // the integer value of the biggest number DECLARE Count : INTEGER CONSTANT EMPTY = "" Max ← −1 FOR Index ← 1 To 10000 IF TagCount[Index] > Max THEN Max ← TagCount[Index] Count ← 1 // there is only one max value MostPopTag ← TagString[Index] ELSE IF TagCount[Index] = Max THEN Count ← Count + 1 // another max value ENDIF ENDIF ENDFOR IF Count = 1 THEN OUTPUT "The most popular hashtag is: ", MostPopTag, "It occurs: ", Max," times.” ELSE OUTPUT "The maximum hashtag count is: ",Max,__ "The number of hashtags with this count is: ", Count ENDIF ENDPROCEDURE 8
Mark scheme, page 16
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2020 © UCLES 2020 Page 16 of 27 Question Answer Marks 5(d) 1 mark for each of the following: 1 Initialise Max to a value less than 1 or to TagCount[1] 2 Loop through all elements 3 Test if TagCount value > Max in a loop 4 and if so set Max to TagCount value 5 and save TagString element (or array index) and set Count to 1 (unless counting is separate) 6 ELSE If TagCount value = Max, increment Count (or via separate loop) 7 Output for single max after the loop 8 Or Output for multiple max after the loop Alternative "two-loop" solution: PROCEDURE OutputMostPop() DECLARE Index : INTEGER DECLARE MostPopTag : STRING DECLARE Max : INTEGER //The integer value of the biggest number DECLARE MaxCount : INTEGER CONSTANT EMPTY = "" Max ← -1 FOR Index ← 1 To 10000 IF TagCount[Index] > Max THEN Max ← TagCount[Index] MostPopTag ← TagString[Index] ENDIF ENDFOR
Mark scheme, page 17
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2020 © UCLES 2020 Page 17 of 27 Question Answer Marks 5(d) MaxCount ← 0 FOR Index ← 1 To 10000 IF TagCount[Index] = Max THEN MaxCount ← MaxCount + 1 ENDIF ENDFOR IF MaxCount = 1 THEN OUTPUT "The most popular hashtag is: ", MostPopTag, ". It occurs: ", Max," times.” ELSE OUTPUT "The mamimum value is: ",Max, ". It occurred ", MaxCount, " times." ENDIF ENDPROCEDURE *** End of Mark Scheme – example program code solutions follow ***
Mark scheme, page 18
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2020 © UCLES 2020 Page 18 of 27 Program Code Example Solutions Q2 (c): Visual Basic Index = 0 Status = FALSE Do While Status <> TRUE Status = TopUp() Index = Index + 1 Loop If Index > 100 Then SetLevel("Super") End If Q2 (c): Pascal Index := 0; Status := FALSE; while Status <> TRUE do begin Status := TopUp(); Index := Index + 1; end; if Index > 100 then SetLevel("Super");
Mark scheme, page 19
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2020 © UCLES 2020 Page 19 of 27 Q2 (c): Python Index = 0 Status = FALSE while Status <> TRUE: Status = TopUp() Index = Index + 1 if Index > 100: SetLevel("Super") Q3: Visual Basic Sub BubbleSort() Dim Temp As Integer Dim NoSwaps As Boolean Dim Boundary, J As Integer Boundary = 4998 Do NoSwaps = TRUE For J = 0 To Boundary If ProdNum(J)> ProdNum(J+1)Then Temp = ProdNum(J) ProdNum(J) = ProdNum(J+1) ProdNum(J+1) = Temp NoSwaps = FALSE End If Next Boundary = Boundary - 1 Loop Until NoSwaps = TRUE End Sub
Mark scheme, page 20
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2020 © UCLES 2020 Page 20 of 27 Q3: Pascal Peocedure BubbleSort(); var Temp: Integer; NoSwaps : Boolean; Boundary, J : Integer; begin Boundary := 4999; repeat NoSwaps := TRUE; for J := 1 To Boundary do begin if ProdNum[J] > ProdNum[J+1] then begin Temp := ProdNum[J]; ProdNum[J] := ProdNum[J+1]; ProdNum[J+1] := Temp; NoSwaps := FALSE; end; end; Boundary := Boundary – 1; until NoSwaps = TRUE; end;
Mark scheme, page 21
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2020 © UCLES 2020 Page 21 of 27 Q3: Python def BubbleSort(): # Temp As Integer # NoSwaps As Boolean # Boundary, J As Integer NoSwaps = False Boundary = 4999 while not NoSwaps: NoSwaps = True for J in range(Boundary): if ProdNum[J]> ProdNum[J+1]: Temp = ProdNum[J] ProdNum[J] = ProdNum[J+1] ProdNum[J+1] = Temp NoSwaps = FALSE Boundary = Boundary – 1
Mark scheme, page 22
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2020 © UCLES 2020 Page 22 of 27 Q5 (b): Visual Basic Function CountHashtag (Message As STRING) As INTEGER Dim TagNum As INTEGER Dim StartPos As INTEGER Dim Found As BOOLEAN TagNum = 0 Found = TRUE Do StartPos = GetStart(Message, TagNum + 1) If StartPos = -1 Then Found = FALSE Else TagNum = TagNum + 1 End If Loop Until No Found Return TagNum End Function
Mark scheme, page 23
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2020 © UCLES 2020 Page 23 of 27 Q5 (b): Pascal Function CountHashtag (Message : STRING) : INTEGER; var TagNum : Integer; StartPos : Integer; Found : Boolean; begin TagNum := 0; Found:= TRUE; repeat StartPos := GetStart(Message, TagNum + 1); if StartPos = -1 then Found := FALSE else TagNum := TagNum + 1; until Not Found; CountHashtag := TagNum; end;
Mark scheme, page 24
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2020 © UCLES 2020 Page 24 of 27 Q5 (b): Python def CountHashtag (Message) # TagNum, StartPos As INTEGER # Found As BOOLEAN TagNum = 0 Found = TRUE while Found: StartPos = GetStart(Message, TagNum + 1) if StartPos == -1: Found = FALSE else: TagNum = TagNum + 1 return TagNum
Mark scheme, page 25
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2020 © UCLES 2020 Page 25 of 27 Q 5 (c): Visual Basic Function IncrementHashtag (HashTag As String) As Boolean Dim Index As Integer Dim Found As Boolean Found = False Index = 1 'First element Do If TagString(Index) = HashTag Then TagCount(Index) = TagCount(Index) + 1 Found = True Else Index = Index + 1 End If Loop Until Index > 10000 Or Found = True Return Found End Function
Mark scheme, page 26
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2020 © UCLES 2020 Page 26 of 27 Q 5 (c): Pascal Function IncrementHashtag (HashTag : String) : Boolean; var Index : Integer; Found : Boolean begin Found := FALSE; Index := 1; //First element repeat If TagString[Index] = HashTag then begin TagCount[Index] := TagCount[Index] + 1; Found := TRUE; end else Index := Index + 1; until Index > 10000 OR Found = TRUE; IncrementHashtag := Found; end;
Mark scheme, page 27
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED October/November 2020 © UCLES 2020 Page 27 of 27 Q 5 (c): Python def IncrementHashtag (HashTag): # Index As Integer # Found As Boolean Found = FALSE Index = 0 #First element while not Found and Index < 10000: if TagString[Index] == HashTag: TagCount[Index] = TagCount[Index] + 1 Found = TRUE else: Index = Index + 1 Return Found
What you needed in this session
Cambridge’s own grade thresholds for 2020 Oct/Nov, Paper 2 · Variant 3. A higher threshold means an easier paper — the bar moves with how the cohort did.