A Level Computer Science 9618 Paper 23, Oct/Nov 2023

Question paper and mark scheme75 marks8 questions

Solve it on ExamPal

Practise

Untimed. Write on the paper and check as you go.

Start

Exam

Timed, with a clock you set, like sitting the real paper.

Start

Opens full screen.

Papers open in

Opening the question paper

Read as textThe questions and the mark scheme as plain text. Easier to read on a phone.

Question paper

9618/23 · Oct/Nov 2023

Download PDF
1

Refer to the insert for the list of pseudocode functions and operators. 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 statementData typeMyVar1‾←Total1 / Total2MyVar2‾←27/10/2023MyVar3‾←"Sum1 / Sum2"MyVar4‾←Result1 AND Result2

[4]
b

Other variables in the program have example values as shown:

VariableValue
ActiveTRUE
Fraction0.2
Code"Ab12345"

Complete the table by evaluating each expression using the example values.

ExpressionEvaluates 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]
2

Data is a 1D array of integers, containing 30 elements. All element values are unique.

Figure 1 of 1 for question 2
a

An algorithm will output the index of the element with the smallest value. Draw a program flowchart to represent the algorithm.

[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]
3

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.

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.

[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]
4

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]
5

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)

[6]
6

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 valueConditionExample
1The last three digits are the same but non-zero."253444"
2The last three digits are zero."253000"
3The 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]
7

A structure chart shows the modular structure of a program: [Structure Chart showing Module-A() calling Sub-Y1() with parameter T1, calling Sub-Y2() with parameter SA, and calling Sub-9() with parameter RA and return value RB, with a curved arrow looping across the module calls]

Figure 1 of 1 for question 7
a

Explain the meaning of the curved arrow symbol which begins and ends at Module-A().

[2]
b(i)

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. Write pseudocode to define MyType.

[3]
b(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]
8

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 nameDescription
STXa single character marking the start of the message (ASCII value 02)
DestinationIDthree numeric characters identifying the destination computer
SourceIDthree numeric characters identifying the source computer
Dataa variable length string containing the data being sent (Minimum length is 1 character)
ETXa single character marking the end of the message (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:

ModuleDescription
GetData()(already written)• returns the data field from a message that has been received• If no message is available, the module waits until one has been received.
ReceiveFile()• takes a file name as a parameter of type string• creates a text file with the given file name (no checking required)• 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.

ModuleDescription
Transmit()(already written)• takes two parameters:∘ a string representing a message∘ an integer representing a port number• transmits the message using the given port
Chat()• takes two parameters:∘ a string representing a Destination ID∘ an integer representing a port number• 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

9618/23 · Oct/Nov 2023

Download PDF

1a · 4 marks

  • 1 mark

    REAL for MyVar1 ← Total1 / Total2

  • 1 mark

    DATE for MyVar2 ← 27/10/2023

  • 1 mark

    STRING for MyVar3 ← "Sum1 / Sum2"

  • 1 mark

    BOOLEAN for MyVar4 ← Result1 AND Result2

1b · 4 marks

  • 1 mark

    FALSE for Fraction >= 0.2 AND NOT Active

  • 1 mark

    33 for INT((Fraction1 * 100) + 13.3)

  • 1 mark

    28 for STR_TO_NUM(MID(Code, 4, 2)) + 5

  • 1 mark

    11 for LENGTH("TRUE" & Code)

1c · 1 mark

  • 1 mark

    The use of a program library (routines)

1d · 2 marks

  • 1 mark

    Type: Adaptive

  • 1 mark

    Reason: The (user) requirement(s) changes // to accommodate legislative changes

2a · 5 marks

  • 1 mark

    Initialise Min to first value in Data and MinIndex to 1

  • 1 mark

    Loop through 29 more values (or 30 values in total)

  • 1 mark

    Compare element from Data[] with Min

  • 1 mark

    Set new Min AND save MinIndex when element value < Min in a loop

  • 1 mark

    Output MinIndex

2b · 2 marks

  • 1 mark

    Simplifies the algorithm // easier to write / understand / test / debug

  • 1 mark

    It is possible to iterate through the values // can use a loop // allows the storage of many values using a single identifier

2c · 2 marks

  • 1 mark

    ARRAY[1:120]

  • 1 mark

    REAL

3a · 3 marks

  • 1 mark

    D3, D4, D1, D2 and D5 in question order or reversed - in any five consecutive locations

  • 1 mark

    FoQ value matches index with D3

  • 1 mark

    EoQ value matches index with D5

3b · 6 marks

  • 1 mark

    If NumItems is / = 8 // (queue) full then jump to step 6

  • 1 mark

    Increment EndOfQueue

  • 1 mark

    If EndOfQueue = 9 then set EndOfQueue to 1

  • 1 mark

    Increment NumItems

  • 1 mark

    Set the Element at the index …

  • 1 mark

    stored in EndOfQueue to value/data/item being added

4a · 6 marks

  • 1 mark

    Procedure heading and ending

  • 1 mark

    Local loop counter Count as integer

  • 1 mark

    Loop to iterate 25 times or more for each unique number

  • 1 mark

    ‘Attempt’ to generate a random number including use of INT() in a loop

  • 1 mark

    Ensure that number generated is greater than previous and change ‘previous’

  • 1 mark

    Output random number after an attempt at MP5 in a loop

4b · 1 mark

  • 1 mark

    Result[x + 1] <= Result[x] // Result[x] >= Result[x + 1]

5 · 6 marks

  • 1 mark

    Row 1 (initialisation)

  • 1 mark

    Iteration 1 – Total 2

  • 1 mark

    Iteration 2 – Total 5

  • 1 mark

    Iteration 3 – Total 10

  • 1 mark

    Iteration 4 – Total 15

  • 1 mark

    Iteration 5 – Total 28 and final Mix[1] = 56

6 · 6 marks

  • 1 mark

    Function heading and ending including parameter and return type

  • 1 mark

    Test for Condition 1

  • 1 mark

    Test for Condition 2

  • 1 mark

    Test for Condition 3

  • 1 mark

    Return the highest value if more than one condition is satisfied

  • 1 mark

    Return zero if no condition matched

7a · 2 marks

  • 1 mark

    iteration / looping

  • 1 mark

    naming all four modules correctly in the correct sequence // e.g. Module-A repeatedly calls Sub-Y1,then SubY2 then Sub-9

7b(i) · 3 marks

  • 1 mark

    TYPE MyType... ENDTYPE

  • 1 mark

    RA as integer and RB3 as string

  • 1 mark

    RC as Boolean

7b(ii) · 2 marks

  • 1 mark

    One mark for BYREF

  • 1 mark

    One mark for the rest of the statement

8a · 7 marks

  • 1 mark

    OPEN file in WRITE mode and subsequently CLOSE

  • 1 mark

    Conditional loop until terminator received

  • 1 mark

    ‘Attempted’ use of GetData() – Ignore CALL …

  • 1 mark

    Fully correct use GetData()to return the data in a loop

  • 1 mark

    Maintain CharCount in a loop

  • 1 mark

    Write each line to the file - except the terminator in a loop

  • 1 mark

    Final output of message giving number of characters written outside loop

8b · 3 marks

  • 1 mark

    If the file being sent contains a line of the string "****"

  • 1 mark

    then the file being written by ReceiveFile() will end at this point // subsequent file lines will be lost

  • 1 mark

    Read the file (at the sending end) to find the number of lines it contains // (Transmitter program) chooses a different terminator string / character that doesn't occur in the file

8c · 7 marks

  • 1 mark

    Conditional loop

  • 1 mark

    Test for terminator in both cases

  • 1 mark

    Use GetData() to get the data from the message

  • 1 mark

    OUTPUT the data in a loop

  • 1 mark

    INPUT the data reply

  • 1 mark

    ‘Attempted ‘ use of Transmit to send it in a loop

  • 1 mark

    Correct formation of parameters to Transmit()

8d · 3 marks

  • 1 mark

    GetData() does not return a value until a message has been received

  • 1 mark

    So once a message has been sent the user has to wait for a reply // chat is half-duplex

  • 1 mark

    If no response allow the receiver to exit chat at any time … // GetData() should immediately return a suitable message // set a time limit // ... which Chat() can detect and respond by allowing the conversation to continue

Questions

  1. 1
    Question 111 marks
    Mark scheme ›
  2. 2
    Question 29 marks
    Mark scheme ›
  3. 3
    Question 39 marks
    Mark scheme ›
  4. 4
    Question 47 marks
    Mark scheme ›
  5. 5
    Question 56 marks
    Mark scheme ›
  6. 6
    Question 66 marks
    Mark scheme ›
  7. 7
    Question 77 marks
    Mark scheme ›
  8. 8
    Question 820 marks
    Mark scheme ›

More 9618 papers

Other papers from Oct/Nov 2023

Solve it on ExamPalStart