Free until 14 Nov · 80% off for the first 100 · Pricing

Computer Science 9618/21 May/June 2024: question paper and mark scheme

Cambridge AS & A Level Computer Science (9618), Paper 2 Fundamental Problem-solving and Programming Skills, May/June 2024. Read both free below, or download them. Done the paper? Get it marked by AI against this mark scheme.

9618_s24_qp_219618_s24_ms_219618/21/M/J/24

Paper
Paper 2 Fundamental Problem-solving and Programming Skills
Total marks
75
Time
2 hours
Code on the paper
9618/21/M/J/24
9618_s24_ms_21.pdf

9618/21 mark scheme, question by question

Each question as it's printed, and the mark scheme's points for it, as text. Diagrams, tables and graphs are in the PDFs above.

Question 111 marks

Question

An algorithm is developed in pseudocode before being coded in a programming language. (a) The following table shows four valid pseudocode assignment statements. Complete the table by giving an appropriate data type to declare each of the variables A, B, C and D. Assignment statement Data type A LEFT(MyName, 1) B Total * 2 C INT(ItemCost) / 3 D "Odd OR Even" [4] (b) Other variables in the program have example values as shown: Variable Value Sorted False Tries 9 ID "ZGAC001" Complete the table by evaluating each expression, using the example values. Expression Evaluates to Tries < 10 AND NOT Sorted Tries MOD 4 TO_LOWER(MID(ID, 3, 1)) LENGTH(ID & "xx") >= Tries [4] (c) The variable names A, B, C and D in part (a) are not good programming practice. (i) State why these variable names are not suitable. …… [1] (ii) Identify one problem that these variable names might cause. …… [1] (iii) The choice of suitable variable names is one example of good programming practice. Give one other example. …… [1]

Mark scheme

1(a) 4 Assignment statement Data type A ← LEFT(MyName, 1) CHAR / STRING B ← Total * 2 INTEGER / REAL C ← INT(ItemCost) / 3 REAL D ← "Odd OR Even" STRING One mark per row 1(b) 4 Expression Evaluates to Tries < 10 AND NOT Sorted TRUE Tries MOD 4 1 TO_LOWER(MID(ID, 3, 1)) 'a' // "a" LENGTH(ID & "xx") >= Tries TRUE One mark per row 1(c)(i) The names do not reflect / indicate the purpose of the variable // the names 1 are not meaningful 1(c)(ii) They make the program more difficult to understand / debug / maintain 1 1(c)(iii) One mark from: 1 Indentation / use of white space Capitalisation of keywords Use of comments Use of modular programming Use of local variables Note: max 1 mark

Question 27 marks

Question

An algorithm has three steps. It will: 1. repeatedly input a pair of numeric values A and B 2. count the number of pairs that are input until A has been greater than B 10 times 3. output the number of pairs that were input. (a) Complete the program flowchart. START INPUT A, B Yes No END [5] (b) Step 1 of the algorithm is changed. A variable ThisSequence is used to enter a sequence of 10 pairs of numeric values, using a single input statement. Following the input of ThisSequence the revised algorithm will extract the pairs of numbers. Describe the variable ThisSequence and how the numbers are extracted. …… [2]

Mark scheme

2(a) 5 One mark per outlined region: 1 Initialise both counts 2 Increment Tries every time a pair is input 3 Compare A > B and increment Count if TRUE 4 Test for Count = 10 (10th time A > B) – MUST include Yes / No labels 5 If so output Tries, otherwise loop 2(b) One mark per point: 2 1 A (variable of type) string will be input // by example e.g. “67,72” 2 A special / identified character would need to be used to separate each numeric value // all numbers are fixed length

Question 38 marks

Question

The diagram shows an Abstract Data Type (ADT) representation of a linked list after data items have been added. • PS is the start pointer. • PF is the free list pointer. • Labels Df, Dc, Db and Dy represent the data items of nodes in the list. • Labels Fg, Fh, Fm and Fw represent the data items of nodes in the free list. • The symbol Ø represents a null pointer. PS Df Dc Db Dy Ø PF Fg Fh Fm Fw Ø (a) Describe the linked list immediately after initialisation, before any data items are added. …… [3] (b) A program will be written to include a linked list to store alphanumeric user IDs. The design uses two variables and two 1D arrays to implement the linked list. Each array element contains data of a single data type and not a record. The statements below describe the design. Complete the statements. The two variables will be of type …… . The two variables will be used as …… to the arrays. The values stored in the two variables will indicate …… …… . The first 1D array will be of type …… . The first 1D array will be used to …… . The second 1D array will be of type …… . The second 1D array will be used to …… . [5]

Mark scheme

3(a) One mark per point: 3 1 The PS contains a null pointer 2 The PF points to the first element on the free list 3 All the nodes are on the free list 3(b) Max 2 marks for 'Variables': 5 The two variables will be of type Integer The two variables will be used as pointers / indexes to the arrays. The values stored in the two variables will indicate the first element in each list The first 1D array will be of type String The first 1D array will be used to store the values // data items // User IDs The second 1D array will be of type Integer The second 1D array will be used to store the pointers // point to next item Mark as follows: One mark for each of the first three rows One mark for both Array 1 rows One mark for both Array 2 rows

Question 46 marks

Question

A global 1D array Data contains 100 elements of type integer. A function Check() will: • total the element values in odd index locations (1, 3, 5 ... 97, 99) • total the element values in even index locations (2, 4, 6 ... 98, 100) • return one of three strings ‘Odd’, ‘Even’ or ‘Same’ to indicate which total is the greater, or whether the totals are the same. Write pseudocode for the function Check(). …… [6]

Mark scheme

4 Example: 6 FUNCTION Check() RETURNS STRING DECLARE Odd, Even, Index : INTEGER Odd ← 0 Even ← 0 FOR Index ← 1 TO 100 IF Index MOD 2 = 0 THEN Even ← Even + Data[Index] ELSE Odd ← Odd + Data[Index] ENDIF NEXT Index ENDFUNCTION Mark as follows: 1. Function heading, ending and return type 2. Declare local variables Odd, Even and Index as integers 3. Initialise Odd and Even 4. Loop for 100 iterations // through array 5. Sum Odd and Even element values in a loop 6. Compare Odd and Even after the loop and Return appropriate string

Question 520 marks

Question

A global 1D array of strings contains three elements which are assigned values as shown: Data[1] "aaaaaa" Data[2] "bbbbbb" Data[3] "cccccc" Procedure Process() manipulates the values in the array. The procedure is written in pseudocode as follows: PROCEDURE Process(Format : STRING) DECLARE Count, Index, L : INTEGER DECLARE Result : STRING DECLARE C : CHAR Result "****" FOR Count 1 TO LENGTH(Format) STEP 2 C MID(Format, Count, 1) L STR_TO_NUM(MID(Format, Count + 1, 1)) Index (Count + 1) DIV 2 CASE OF C 'X' : Result TO_UPPER(Data[Index]) 'Y' : Result TO_LOWER(Data[Index]) 'Z' : Result "**" & Data[Index] ENDCASE Data[Index] LEFT(Result, L) NEXT Count ENDPROCEDURE (a) Complete the trace table by dry running the procedure when it is called as follows: CALL Process("X3Y2W4") Count C L Index Result Data[1] Data[2] Data[3] [6] (b) The procedure is to be modified. If variable C is assigned a value other than 'X', 'Y' or 'Z', then procedure Error() is called and passed the value of variable C as a parameter. This modification can be implemented by adding a single line of pseudocode. (i) Write the single line of pseudocode. …… [1] (ii) State where this new line should be placed. …… [1]

Mark scheme

5(a) 6 One mark per zone. 5(b)(i) OTHERWISE : CALL Error(C) 1 5(b)(ii) After the 'Z' clause in the CASE construct // before the ENDCASE 1

Question 68 marks

Question

Three points on a grid form a triangle with sides of length A, B and C as shown in the example: y 10 9 8 7 6 5 B C 4 3 2 A 1 x 0 1 2 3 4 5 6 7 8 9 10 A triangle is said to be right-angled if the following test is true (where A is the length of the longest side): A2 = B2 + C2 A2 means A multiplied by A, for example 32 means 3 × 3 which evaluates to 9 You can calculate A2, B2 and C2 by using the coordinates of the endpoints of each line. For example, B2 is calculated as follows: y 10 9 8 7 P2 6 (x2, y2) 5 B 4 3 P1 2 (x1, y1) 1 x 0 1 2 3 4 5 6 7 8 9 10 The endpoints, P1 and P2, have the coordinates (3, 2) and (6, 6). The value B2 is given by the formula: B2 = (x1 − x2)2 + (y1 − y2)2 In this example: B2 = (3 − 6)2 + (2 − 6)2 B2 = (–3)2 + (–4)2 B2 = 9 + 16 B2 = 25 (a) A function IsRA() will: • take three sets of integers as parameters representing the coordinates of the three endpoints that form a triangle • return TRUE if the endpoints form a right-angled triangle, otherwise return FALSE. In pseudocode, the operator ‘^’ represents an exponent, which is the number of times a value is multiplied by itself. For example, the expression Value2 may be written in pseudocode as Value ^ 2 Complete the pseudocode for the function IsRA(). FUNCTION IsRA(x1, y1, x2, y2, x3, y3 : INTEGER) RETURNS BOOLEAN ENDFUNCTION [6] (b) The test used to check if a triangle is right-angled can be written in two ways: A2 = B2 + C2 or A = √(B2 + C2) The symbol √ represents the square root operation. For example, √81 = 9 A new function SQRT() is written to perform the square root operation. The function takes an integer number as a parameter and returns a positive real value representing the square root of the number. During testing it is found that the SQRT() function returns a value that is only accurate to 4 decimal places. For example, SQRT(25) returns 5.0000125 rather than the correct value of 5.0 The function IsRA() from part (a) is modified to use the new SQRT() function to test if a triangle is right-angled. Describe a problem that might occur when using the modified IsRA() function and suggest a solution that still allows the SQRT() function to be used. Problem …… Solution …… [2]

Mark scheme

6(a) FUNCTION IsRA(x1, y1, x2, y2, x3, y3 : INTEGER) RETURNS 6 BOOLEAN DECLARE Len1, Len2, Len3 : INTEGER Len1 ← (x1 - x2) ^ 2 + (y1 - y2) ^ 2 Len2 ← (x1 - x3) ^ 2 + (y1 - y3) ^ 2 Len3 ← (x2 - x3) ^ 2 + (y2 - y3) ^ 2 IF (Len1 = Len2 + Len3) OR__ (Len2 = Len1 + Len3) OR__ (Len3 = Len1 + Len2) THEN RETURN TRUE ELSE RETURN FALSE ENDIF ENDFUNCTION Mark as follows: 1 Calculate the square of the length of at least one side 2 Calculation of all three lengths squared correctly 3 One correct comparison of square of three lengths 4 All three comparisons… 5 combined using logical operators / nested IF // completely correct selection 6 Return result correctly in both cases 6(b) 1 mark for statement of problem: 2 Problem: The function will return an incorrect value // the test will fail 1 mark for solution: Solution: Round the calculated values (to a known number of decimal places) Define a threshold below which any difference can be ignored

Question 712 marks

Question

A fitness club has a computerised membership system. The fitness club offers a number of different exercise classes. The following information is stored for each club member: name, home address, email address, mobile phone number, date of birth and the exercise(s) they are interested in. (a) When an exercise class is planned, a new module will send personalised text messages to each member who has expressed an interest in that exercise. Members wishing to join the class send a text message back. Members may decide not to receive future text messages by replying with the message ‘STOP’. The process of abstraction is used to filter out unnecessary information. (i) State one advantage of applying abstraction to this problem. …… [1] (ii) Identify three items of information that will be required by the new module. Justify your choices with reference to the given scenario. Item 1 required …… Justification …… Item 2 required …… Justification …… Item 3 required …… Justification …… [3] (iii) Identify two operations that would be required to process data when the new module receives a text message back from a member. Operation 1 …… Operation 2 …… [2] (b) The structure chart illustrates part of the membership program: Update A P2 T1 Name P1 Sub-A Sub-B Sub-C Data item notes: • Name contains the name of a club member • P1 and T1 are of type real. (i) Explain the meaning of the diamond symbol (labelled with the letter A) in the chart. …… [2] (ii) Write the pseudocode module headers for Sub-A and Sub-B. Sub-A Sub-B [4]

Mark scheme

7(a)(i) To make the solution easier to design / implement / solve 1 7(a)(ii) One mark per item and justification 3 Item: mobile phone number Justification: to send the text message Item: name Justification: to personalise the text message Item: exercise interest Justification: to determine whether this member would be interested 7(a)(iii) Examples include: 2 Add a member to a list of those interested in the new class Remove the member from future SMS messages Read/process Message Identify who from One mark for each. Max 2 marks 7(b)(i) 2 Means that Update calls (one of) either Sub-A, Sub-B or Sub-C One mark for each point: reference to selection / decision / if naming all four modules correctly 7(b)(ii) PROCEDURE Sub-A (Name : STRING, BYREF P2 : BOOLEAN) 4 FUNCTION Sub-B (P1 : REAL) RETURNS REAL One mark per underlined part in each case

Question 815 marks

Question

A teacher is designing a program to process pseudocode projects written by her students. Each student project is stored in a text file. The process is split into a number of stages. Each stage performs a different task and creates a new file named as shown: File name Comment MichaelAday_src.txt student project file produced by student Michael Aday MichaelAday_S1.txt file produced by stage 1 MichaelAday_S2.txt file produced by stage 2 The teacher has defined the first program module as follows: Module Description DeleteComment() • called with a parameter of type string representing a line of pseudocode from a student’s project file • returns the line after removing any comments Note on comments: A comment starts with two forward slash characters and includes all the remaining characters on the line. The following example shows a string before and after the comment has been removed: Before: IF X2 > 13 THEN //check if limit exceeded After: IF X2 > 13 THEN (a) Complete the pseudocode for module DeleteComment(). FUNCTION DeleteComment(Line : STRING) RETURNS STRING ENDFUNCTION [8] (b) A second module is defined: Module Description Stage_1() • called with a parameter of type string representing a student name • creates a new stage 1 file • copies each line from the student’s project file to the stage 1 file after removing any comment from each line • does not write blank lines to the stage 1 file • returns the number of lines written to the stage 1 file Write pseudocode for module Stage_1(). Module DeleteComment() must be used in your solution. …… [7]

Mark scheme

8(a) FUNCTION DeleteComment(Line : STRING) RETURNS STRING 8 DECLARE NewLine, TwoChars : STRING DECLARE Count, TrimTo : INTEGER CONSTANT Comment = "//" NewLine ← Line TrimTo ← 0 Count ← 1 WHILE Count < LENGTH(Line) AND TrimTo = 0 TwoChars ← MID(Line, Count, 2) // extract 2 chars IF TwoChars = Comment THEN TrimTo ← Count ENDIF Count ← Count + 1 ENDWHILE IF TrimTo <> 0 THEN NewLine ← LEFT(Line, TrimTo - 1) ENDIF RETURN NewLine ENDFUNCTION Mark as follows: 1 Loop to length of Line (parameter) // length of Line -1 2 Terminate loop on first double slash 3 Attempt to extract one/two characters in a loop 4 Check for "//" after attempt at extraction in a loop 5 Record start position of comment // Calculate amount of trim required 6 Attempt to trim Line from start of comment 7 Completely correct trimmed Line from start of comment 8 Return Line after a reasonable overall attempt 8(b) Example: 7 FUNCTION Stage_1(StudentName : STRING) RETURNS INTEGER DECLARE OldFile, NewFile, Line : STRING DECLARE Count : INTEGER OldFile ← StudentName & "_src.txt" NewFile ← StudentName & "_S1.txt" OPENFILE OldFile FOR READ OPENFILE NewFile FOR WRITE Count ← 0 WHILE NOT EOF(OldFile) READFILE OldFile, Line Line ← DeleteComment(Line) IF LENGTH(Line) <> 0 THEN WRITEFILE NewFile, Line Count ← Count + 1 ENDIF ENDWHILE CLOSEFILE OldFile CLOSEFILE NewFile RETURN Count ENDFUNCTION Mark as follows: 1 Generate filenames condone missing “_” 2 Open both files in correct modes and subsequently close 3 Loop to EOF(OldFile) 4 Read a line from OldFile and execute DeleteComment()in a loop 5 Skip blank lines after DeleteComment()in a loop 6 Write Line to stage 1 file and increment Count 7 Return the number of lines after a reasonable attempt at counting

Checked your answers against these? Let AI mark the whole paper, on your own working.

Mark my 9618/21

How this paper is marked

Examiners follow the generic marking principles at the front of the scheme, then each question's points: method (M), accuracy (A) and independent (B) marks, error carried forward where the scheme allows it, and positive marking, so you're credited for what you got right.

Check your answers against it

Done this paper? Upload your script and CIE Buddy's AI marker marks it question by question against this exact scheme, puts the ticks on your own working and says what each lost mark needed.

9618/21 in other series

Find another Computer Science paper

Every AS & A Level Computer Science mark scheme

Question papers and mark schemes © Cambridge University Press & Assessment. CIE Buddy is independent and not connected to Cambridge.

9618/21 questions

Where can I find the 9618/21 May/June 2024 mark scheme?

On this page, free: the mark scheme for AS & A Level Computer Science 9618/21, May/June 2024 (9618_s24_ms_21), and the question paper (9618_s24_qp_21), to read or download, with each question's marking points written out underneath.

How many marks is 9618/21 out of?

Computer Science 9618/21 for May/June 2024 is out of 75 marks, with 2 hours to answer it.

Can I get my 9618/21 answers marked?

Yes. Upload your answers to 9618/21/M/J/24 as a PDF or photos, and CIE Buddy marks every question against this paper's official mark scheme, using Cambridge's marking rules. You get your score, each lost mark explained on your own script, and the topics to revise. It's a guide, not an official Cambridge grade.