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

Computer Science 9618/23 October/November 2023: question paper and mark scheme

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

9618_w23_qp_239618_w23_ms_239618/23/O/N/23

Paper
Paper 2 Fundamental Problem-solving and Programming Skills
Total marks
75
Time
2 hours
Code on the paper
9618/23/O/N/23
9618_w23_ms_23.pdf

9618/23 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

A program is being developed in pseudocode before being converted into a programming language. (a) The following table shows four valid pseudocode assignment statements. Complete the table by giving the data type that should be used to declare the variable underlined in each assignment statement. Assignment statement Data type MyVar1 ← Total1 / Total2 MyVar2 ← 27/10/2023 MyVar3 ← "Sum1 / Sum2" MyVar4 ← Result1 AND Result2 [4] (b) Other variables in the program have example values as shown: Variable Value Active TRUE Fraction 0.2 Code "Ab12345" Complete the table by evaluating each expression using the example values. Expression Evaluates to Fraction >= 0.2 AND NOT Active INT((Fraction * 100) + 13.3) STR_TO_NUM(MID(Code, 4, 2)) + 5 LENGTH("TRUE" & Code) [4] (c) The program makes use of complex statistical functions. The required functions are not built-in to the programming language and are too complicated for the programmer to write. One solution would be to employ another programmer who has experience of writing these functions, as there is no time to train the existing programmer. State one other way that these functions may be provided for inclusion in the program. …… [1] (d) The hardware that runs the program is changed and the program needs to be modified so that it works with the new hardware. Identify the type of maintenance that this represents and give one other reason why this type of maintenance may be needed. Type …… Reason …… [2]

Mark scheme

1(a) 4 Assignment statement Data type MyVar1 ← Total1 / Total2 REAL MyVar2 ← 27/10/2023 DATE MyVar3 ← "Sum1 / Sum2" STRING MyVar4 ← Result1 AND Result2 BOOLEAN 1(b) 4 Expression Evaluates to Fraction >= 0.2 AND NOT Active FALSE INT((Fraction1 * 100) + 13.3) 33 STR_TO_NUM(MID(Code, 4, 2)) + 5 28 LENGTH("TRUE" & Code) 11 1(c) The use of a program library (routines) 1 1(d) MP1 Type: Adaptive 2 MP2 Reason: The (user) requirement(s) changes // to accommodate legislative changes

Question 29 marks

Question

Data is a 1D array of integers, containing 30 elements. All element values are unique. (a) An algorithm will output the index of the element with the smallest value. Draw a program flowchart to represent the algorithm. START END [5] (b) The 30 data values could have been stored in separate variables rather than in an array. Explain the benefits of using an array when designing a solution to part (a). …… [2] (c) The requirement changes. Array Data needs to hold 120 elements and each value may include a decimal place. Write a pseudocode statement to declare the modified array. …… [2]

Mark scheme

2(a) 5 MP1 Initialise Min to first value in Data and MinIndex to 1 MP2 Loop through 29 more values (or 30 values in total) MP3 Compare element from Data[] with Min MP4 Set new Min AND save MinIndex when element value < Min in a loop MP5 Output MinIndex 2(b) MP1 Simplifies the algorithm // easier to write / understand / test / debug 2 MP2 It is possible to iterate through the values // can use a loop // allows the storage of many values using a single identifier 2(c) One mark per underlined section 2 DECLARE Data : ARRAY[1:120] OF REAL

Question 39 marks

Question

The diagram represents a queue Abstract Data Type (ADT). The organisation of this queue may be summarised as follows: • The FrontOfQueue pointer points to the next data item to be removed. • The EndOfQueue pointer points to the last data item added. Queue D3 ← FrontOfQueue D4 D1 D2 D5 ← EndOfQueue The queue is implemented using three variables and a 1D array of eight elements as shown. The variable NumItems stores the number of items in the queue. The pointer variables store indices (index numbers) of the array. (a) Complete the diagram to represent the state of the queue as shown above. Index Array 1 2 3 4 Variable 5 FrontOfQueue 6 EndOfQueue 7 NumItems 5 8 [3] (b) A module AddTo() will add a value to the queue by manipulating the array and variables in part (a). The queue implementation is circular. When pointers reach the end of the queue, they will ‘wrap around’ to the beginning. Before a value can be added to the queue, it is necessary to check the queue is not full. The algorithm to add a value to the queue is expressed in six steps. Complete the steps. 1. If NumItems …… then jump to step 6. 2. Increment …… . 3. If …… then set EndOfQueue to …… . 4. Increment …… . 5. Set the …… at the index stored in …… to the …… being added. 6. Stop. [6]

Mark scheme

3(a) 3 : MP1 D3, D4, D1, D2 and D5 in question order or reversed - in any five consecutive locations MP2 FoQ value matches index with D3 MP3 EoQ value matches index with D5 3(b) MP1 If NumItems is / = 8 // (queue) full then jump to step 6 6 MP2 Increment EndOfQueue MP3 If EndOfQueue = 9 then set EndOfQueue to 1 MP4 Increment NumItems MP5 Set the Element at the index … MP6 stored in EndOfQueue to value/data/item being added Mark as follows: Steps 1 to 4: One mark for gaps filled as shown Step 5: One mark for 'element' and one mark for other two terms

Question 47 marks

Question

A procedure RandList() will output a sequence of 25 random integers, where each integer is larger than the previous one. (a) Write pseudocode for procedure RandList(). …… [6] (b) Procedure RandList() is modified so that the random numbers are also written into a 1D array Result. A new module is written to confirm that the numbers in the array are in ascending order. This module contains an IF statement that performs a comparison between elements: IF (Result[x + 1] = Result[x]) OR (Result[x] > Result[x + 1]) THEN Sequence FALSE ← ENDIF Write a simplified version of the conditional clause. …… [1]

Mark scheme

4(a) PROCEDURE RandList() 6 DECLARE Count, BaseNum, ThisNum : INTEGER CONSTANT StepVal = 10 BaseNum ← 0 FOR Count ← 1 TO 25 ThisNum ← BaseNum + INT(RAND(StepVal)) OUTPUT ThisNum BaseNum ← BaseNum + StepVal NEXT Count ENDPROCEDURE MP1 Procedure heading and ending MP2 Local loop counter Count as integer MP3 Loop to iterate 25 times or more for each unique number MP4 ‘Attempt’ to generate a random number including use of INT() in a loop MP5 Ensure that number generated is greater than previous and change ‘previous’ MP6 Output random number after an attempt at MP5 in a loop 4(b) One mark for simplified logical expression: 1 MP1 Result[x + 1] <= Result[x] ALTERNATIVE SOLUTION: Result[x] >= Result[x + 1]

Question 528 marks

Question

A global 1D array of integers contains four elements, which are assigned values as shown: Mix[1] ←4 Mix[2] ←2 Mix[3] ←3 Mix[4] ←5 A procedure Process() manipulates the values in the array. The procedure is written in pseudocode as follows: PROCEDURE Process(Start : INTEGER) DECLARE Value, Index, Total : INTEGER Index ← Start Total ←0 WHILE Total < 20 Value ←Mix[Index] Total ←Total + Value IF Index < 4 THEN Mix[Index] ← Mix[Index] + Mix[Index+1] ELSE Mix[Index] ← Mix[Index] + Mix[1] ENDIF Index ← (Value MOD 4) + 1 ENDWHILE Mix[1] ← Total * Index ENDPROCEDURE Complete the trace table on the opposite page by dry running the procedure when it is called as follows: CALL Process(2) Index Value Total Mix[1] Mix[2] Mix[3] Mix[4] [6]

Mark scheme

5 6 MP1 Row 1 (initialisation) Each iteration (1 – 5): MP2 1 – Total 2 MP3 2 – Total 5 MP4 3 – Total 10 MP5 4 – Total 15 MP6 5 – Total 28 and final Mix[1] = 56

Question 66 marks

Question

A function TestNum() will take a six-digit string as a parameter. The function will test whether the string meets certain conditions and will return an integer value as follows: Return value Condition Example 1 The last three digits are the same but non-zero. "253444" 2 The last three digits are zero. "253000" 3 The first three and last three digits are the same. "410410" The function will return the highest possible value for the given string. If the string does not meet any of the conditions, zero is returned. Write pseudocode for function TestNum(). Assume that the parameter is valid. …… [6]

Mark scheme

6 6 FUNCTION TestNum(ThisNum : STRING) RETURNS INTEGER IF LEFT(ThisNum,3) = RIGHT(ThisNum 3) THEN RETURN 3 ENDIF IF RIGHT(ThisNum, 3) = "000" THEN RETURN 2 ENDIF IF MID(ThisNum, 4, 1) = MID(ThisNum, 5, 1)__ AND MID(ThisNum, 5, 1) = MID(ThisNum, 6, 1) THEN RETURN 1 ENDIF RETURN 0 ENDFUNCTION MP1 Function heading and ending including parameter and return type MP2 Test for Condition 1 MP3 Test for Condition 2 MP4 Test for Condition 3 MP5 Return the highest value if more than one condition is satisfied MP6 Return zero if no condition matched

Question 77 marks

Question

A structure chart shows the modular structure of a program: Module-A() T1 RA SA RB Sub-Y1() Sub-Y2() Sub-9() (a) Explain the meaning of the curved arrow symbol which begins and ends at Module-A(). …… [2] (b) The structure chart shows that Sub-9() is a function. A Boolean value is returned by Sub-9() for processing by Module-A(). The original parameter RA is of type integer and RB is of type string. A record type MyType will be defined with three fields to store the values passed between the two modules. (i) Write pseudocode to define MyType. …… [3] (ii) The design is modified and Sub-9() is changed to a procedure. The procedure will be called with a single parameter of type MyType. Write the pseudocode header for procedure Sub-9(). …… [2]

Mark scheme

7(a) MP1 iteration / looping 2 MP2 naming all four modules correctly in the correct sequence // e.g. Module-A repeatedly calls Sub-Y1,then SubY2 then Sub-9 7(b)(i) TYPE MyType 3 DECLARE RA : INTEGER DECLARE RB : STRING DECLARE RC : BOOLEAN ENDTYPE MP1 TYPE MyType... ENDTYPE MP2 RA as integer and RB3 as string MP3 RC as Boolean 7(b)(ii) PROCEDURE Sub-9(BYREF Param : MyType) 2 MP 1 One mark for BYREF MP 2 One mark for the rest of the statement

Question 820 marks

Question

A class of students are developing a program to send data between computers. Many computers are connected together to form a wired network. Serial ports are used to connect one computer to another. Each computer: • is assigned a unique three-digit ID • has three ports, each identified by an integer value • is connected to between one and three other computers. Messages are sent between computers as a string of characters organised into fields as shown: <STX><DestinationID><SourceID><Data><ETX> Field name Description a single character marking the start of the message STX (ASCII value 02) DestinationID three numeric characters identifying the destination computer SourceID three numeric characters identifying the source computer a variable length string containing the data being sent Data (Minimum length is 1 character) a single character marking the end of the message ETX (ASCII value 03) For example, the following message contains the data "Hello Jack" being sent from computer "202" to computer "454": <STX>"454202Hello Jack"<ETX> Each computer will run a copy of the same program. Each program will contain a global variable MyID of type string which contains the unique ID of the computer in which the program is running. The first two program modules are defined as follows: Module Description GetData() • returns the data field from a message that has been received (already written) • If no message is available, the module waits until one has been received. • takes a file name as a parameter of type string • creates a text file with the given file name (no checking required) ReceiveFile() • writes the data field returned by GetData() to the file • repeats until the data field is "****", which is not written to the file • outputs a final message giving the total number of characters written to the file, for example: 132456 characters were written to newfile.txt (a) Write pseudocode for module ReceiveFile(). Module GetData() has already been written and must be used. …… [7] (b) The use of the string "****" as explained in the module description for ReceiveFile() may cause a problem. Explain the problem and suggest a solution. Problem …… Solution …… [3] (c) Two new modules are defined, which will allow two users to exchange messages. Module Description • takes two parameters: Transmit() ○ a string representing a message (already written) ○ an integer representing a port number • transmits the message using the given port • takes two parameters: ○ a string representing a Destination ID ○ an integer representing a port number Chat() • extracts data from a received message using GetData() and outputs it • forms a message using data input by the user and sends it using Transmit() • repeats until either the output string or the sent string is "Bye" Reminders: • Each program contains a global variable MyID of type string which contains the unique ID of the computer in which the program is running. • Messages are sent between computers as a string of characters organised into fields as shown: <STX><DestinationID><SourceID><Data><ETX> Write pseudocode for module Chat(). Modules GetData() and Transmit() must be used. …… [7] (d) Module GetData() returns the data field from a message that has been received. If no message is available, the module waits until one has been received. Explain the limitation of this on module Chat() from part (c). Describe a modification to GetData() to address this limitation. Limitation …… Modification …… [3]

Mark scheme

8(a) PROCEDURE ReceiveFile(FileName : STRING) 7 DECLARE FileData : STRING DECLARE CharCount : INTEGER CONSTANT Terminator = "****" OPENFILE FileName FOR WRITE FileData ← GetData() CharCount ← 0 WHILE FileData <> Terminator WRITEFILE FileName, FileData CharCount ← CharCount + LENGTH(FileData) FileData ← GetData() ENDWHILE CLOSEFILE FileName OUTPUT CharCount (, " characters were written to ", FileName) ENDPROCEDURE MP1 OPEN file in WRITE mode and subsequently CLOSE MP2 Conditional loop until terminator received MP3 ‘Attempted’ use of GetData() – Ignore CALL … MP4 Fully correct use GetData()to return the data in a loop MP5 Maintain CharCount in a loop MP6 Write each line to the file - except the terminator in a loop MP7 Final output of message giving number of characters written outside loop 8(b) Max 3 marks 3 Problem: • If the file being sent contains a line of the string "****" • then the file being written by ReceiveFile() will end at this point // subsequent file lines will be lost Solution: • Read the file (at the sending end) to find the number of lines it contains • Send an initial message which defines the number of lines in the file ALTERNATIVE SOLUTION: • (Transmitter program) chooses a different terminator string / character that doesn't occur in the file • Transmitter program sends the terminator string / character before first line of file / before the transfer begins 8(c) PROCEDURE Chat(Destination : STRING, Port : INTEGER) 7 DECLARE Data : STRING DECLARE Finished : BOOLEAN CONSTANT Terminator = "Bye" CONSTANT STX = CHR(2) CONSTANT ETX = CHR(3) Finished ← FALSE REPEAT Data ← GetData() OUTPUT Data IF Data = Terminator THEN Finished ← TRUE ENDIF IF NOT Finished THEN //about to reply INPUT Data Transmit(STX & Destination & MyID & Data & ETX, Port) IF Data = Terminator THEN Finished ← TRUE ENDIF ENDIF UNTIL Finished = TRUE ENDPROCEDURE Conditional loop MP1 Conditional loop MP2 Test for terminator in both cases MP3 Use GetData() to get the data from the message MP4 OUTPUT the data in a loop MP5 INPUT the data reply MP6 ‘Attempted ‘ use of Transmit to send it in a loop MP7 Correct formation of parameters to Transmit() 8(d) Note: Max 3 marks (from either limitation or modification list) 3 Limitation: 1 GetData() does not return a value until a message has been received 2 So once a message has been sent the user has to wait for a reply // chat is half-duplex Modification: 3 If no response allow the receiver to exit chat at any time … 4 GetData() should immediately return a suitable message // set a time limit 5 ... which Chat() can detect and respond by allowing the conversation to continue

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

Mark my 9618/23

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/23 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/23 questions

Where can I find the 9618/23 October/November 2023 mark scheme?

On this page, free: the mark scheme for AS & A Level Computer Science 9618/23, October/November 2023 (9618_w23_ms_23), and the question paper (9618_w23_qp_23), to read or download, with each question's marking points written out underneath.

How many marks is 9618/23 out of?

Computer Science 9618/23 for October/November 2023 is out of 75 marks, with 2 hours to answer it.

Can I get my 9618/23 answers marked?

Yes. Upload your answers to 9618/23/O/N/23 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.