A Level Computer Science 9618 Paper 22, 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/22 · Oct/Nov 2023

Download PDF
1

Refer to the insert for the list of pseudocode functions and operators. 1 A shop sells car accessories. A customer order is created if an item cannot be supplied from current stock. A program is being developed to create and manage the customer orders.

a

The following identifier table shows some of the data that will be stored for each order. Complete the identifier table by adding meaningful variable names and appropriate data types.

Example valueExplanationVariable nameData type
"Mr Khan"The name of the customer
3The number of items in the order
TRUETo indicate whether this is a new customer
15.75The deposit paid by the customer
[4]
b

Other variables in the program have example values as shown:

VariableExample value
Total124.00
DepRate2.00
Description"AB12345:Cleaning Brush (small)"

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

ExpressionEvaluates to
(Total * DepRate) + 1.5
RIGHT(Description, 7)
(LENGTH(Description) - 8) > 16
NUM_TO_STR(INT(DepRate * 10)) & '%'
[4]
c

The data that needs to be stored for each customer order in part (a) is not all of the same type. Describe an effective way of storing this data for many customer orders while the program is running.

[3]
2

An algorithm will: 1. input a sequence of integer values, one at a time 2. ignore all values until the value 27 is input, then sum the remaining values in the sequence 3. stop summing values when the value 0 is input and then output the sum of the values.

Figure 1 of 1 for question 2
a

Draw a program flowchart to represent the algorithm.

[5]
b

The solution to the algorithm includes iteration. Give the name of a suitable loop structure that could be used. Justify your answer. Name ........................................................................................................................................ Justification ............................................................................................................................... ...................................................................................................................................................

[2]
3

The diagram represents a linked list Abstract Data Type (ADT). • Ptr1 is the start pointer. Ptr2 is the free list pointer. • Labels D40, D32, D11 and D100 represent the data items of nodes in the list. • Labels F1, F2, F3 and F4 represent the data items of nodes in the free list. • The symbol Ø represents a null pointer.

a

The linked list is implemented using two variables and two 1D arrays as shown. The pointer variables and the elements of the Pointer array store the indices (index numbers) of elements in the Data array. Complete the diagram to show how the linked list as shown above may be represented using the variables and arrays.

[5]
b

The original linked list is to be modified. A new node D6 is inserted between nodes D32 and D11. The algorithm required is expressed in four steps as shown. Complete the steps. 1. Assign the data item .................................. to .................................. . 2. Set the .................................. of this node to point to .................................. . 3. Set Ptr2 to point to .................................. . 4. Set pointer of .................................. to point to .................................. .

[4]
4

A procedure Count() will: 1. input a value (all values will be positive integers) 2. count the number of odd values and count the number of even values 3. repeat from step 1 until the value input is 99 4. output the two count values, with a suitable message. The value 99 must not be counted.

a

Write pseudocode for the procedure Count().

[6]
b

The procedure Count() is to be tested. Typical test data would consist of odd and even values, for example: 23, 5, 64, 100, 2002, 1, 8, 900, 99 The purpose of this test would be to test a typical mix of even and odd values and check the totals. Give three test data sequences that may be used to test different aspects of the procedure. Do not include invalid data. Sequence 1: Test data ................................................................................................................................... Purpose of test. ........................................................................................................................ ................................................................................................................................................... Sequence 2: Test data ................................................................................................................................... Purpose of test. ........................................................................................................................ ................................................................................................................................................... Sequence 3: Test data ................................................................................................................................... Purpose of test. ........................................................................................................................ ...................................................................................................................................................

[3]
5

A global 1D array of integers contains four elements, which are assigned values as shown: Mix[1] ← 1 Mix[2] ← 3 Mix[3] ← 4 Mix[4] ← 2 A procedure Process() manipulates the values in the array. The procedure is written in pseudocode: PROCEDURE Process(Start : INTEGER) DECLARE Value, Index, Count : INTEGER Index ← Start Count ← 0 REPEAT Value ← Mix[Index] Mix[Index] ← Mix[Index] - 1 Index ← Value Count ← Count + 1 UNTIL Count = 5 Mix[4] ← Count * Index ENDPROCEDURE Complete the trace table on the opposite page by dry running the procedure when it is called as follows: CALL Process(3)

[6]
6
a

A procedure CreateFiles() will take two parameters: • a string representing a file name • an integer representing the number of files to be created. The procedure will create the number of text files specified. Each file is given a different name. Each file name is formed by concatenating the file name with a suffix based on the file number. The suffix is always three characters. For example, the call CreateFiles("TestData", 3) would result in the creation of the three files, TestData.001, TestData.002 and TestData.003. Each file will contain a single line. For example, file TestData.002 would contain the string: This is File TestData.002 Write pseudocode for CreateFiles(). Assume both parameters are valid and that the integer value is between 1 and 999, inclusive.

[6]
b(i)

A module CheckFiles() will count the number of files produced by CreateFiles() in part (a). CheckFiles() will take a string representing a file name and return the number of files found. Identify the type of module that should be used for CheckFiles().

[1]
b(ii)

Write the module header for CheckFiles().

[1]
b(iii)

State the file mode that should be used in CheckFiles().

[1]
7

A program contains six modules: Pseudocode module header PROCEDURE Module-A() PROCEDURE Module-X(T1 : INTEGER, S2 : REAL) PROCEDURE Reset(BYREF Code : INTEGER) FUNCTION Restore(OldCode : INTEGER) RETURNS BOOLEAN FUNCTION Module-Y(RA : INTEGER, RB : BOOLEAN) RETURNS BOOLEAN FUNCTION Module-Z(SA : INTEGER) RETURNS INTEGER Module-X() calls Reset() Module-Y() calls Restore()

Figure 1 of 1 for question 7
a

Complete the structure chart for these modules.

[4]
b

Explain the meaning of the diamond symbol as used in the diagram in part (a).

[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. Data is sent as individual message strings. Each string contains the destination ID (the ID of the computer that is to receive the message) followed by the data: <DestinationID><Data> Messages may pass through several computers on the way to their destination. When a message arrives at a computer, that is not the destination, the program needs to forward it on to another computer using one of its serial ports. The port to use is obtained from information that is stored in an array RouteTable. RouteTable is a global 2D array of integers. It is declared in pseudocode as follows: DECLARE RouteTable : ARRAY[1:6,1:3] OF INTEGER The values in the first two columns of RouteTable define a range of ID values. Column 3 gives the corresponding port number to use when forwarding the message to a computer with an ID within this range. For example, the contents of RouteTable could be:

Column 1Column 2Column 3
Row 11001991
Row 22002592
Row 3−1<undefined><undefined>
Row 42603992
Row 54005993
Row 66009991

In this example, a message that arrives with a DestinationID of "283" will be forwarded using port 2. Row 3 in the example shows an unused row. These may occur anywhere. Unused rows have the column 1 element set to −1. The value of unused elements in the other two columns is undefined.

a

The programmer has defined the first program module as follows:

ModuleDescription
GetPort()• takes a DestinationID as a parameter of type string<br>• searches for the range corresponding to the DestinationID in the array<br>• returns the port number, or returns −1 if no corresponding range is found

Write pseudocode for module GetPort(). Assume DestinationID contains a valid three-digit string.

[7]
b

Copies of the same program will run on each computer. The program contains a global variable MyID of type string, which contains the unique ID of the computer in which the program is running. When messages are received, they are placed on one of two stacks. Stack 1 is used for messages that have reached their destination and stack 2 is used for messages that will be forwarded on to another computer. Additional modules are defined:

ModuleDescription
StackMsg()<br>(already written)• takes two parameters:<br> ○ a string representing a message<br> ○ an integer representing the stack number<br>• adds the message to the required stack<br>• returns TRUE if the message is added to the required stack, otherwise returns FALSE
ProcessMsg()• takes a message as a parameter of type string<br>• ignores any message with a zero-length data field<br>• extract the DestinationID from the message<br>• checks whether the DestinationID is this computer or whether the message is to be forwarded<br>• uses StackMsg() to add the message to the appropriate stack<br>• outputs an error if the message could not be added to the stack

Write pseudocode for module ProcessMsg(). Module StackMsg() must be used.

[7]
c(i)

The program contains a module GetFile() which receives text files sent from another computer. Lines from the file are sent one at a time. Each message contains one line and ProcessMsg() from part (b) adds each message as it is received onto stack 1. Module GetFile() removes messages from stack 1 and writes the data to a text file. There is a problem. Under certain circumstances, the received file does not appear as expected. Assume that while a file is being received ProcessMsg() receives only messages containing lines from the file. Describe the circumstances and explain the problem. Circumstances .................................................................................................................. ........................................................................................................................................... Explanation ....................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ...........................................................................................................................................

[3]
c(ii)

Suggest a more appropriate Abstract Data Type that could be used to store the messages that would not have the same problem.

[1]

Mark scheme

9618/22 · Oct/Nov 2023

Download PDF

1a · 4 marks

  • 1 mark

    "Mr Khan" / The name of the customer: CustomerName, STRING

  • 1 mark

    3 / The number of items in the order: NumItems, INTEGER

  • 1 mark

    TRUE / A value to indicate whether this is a new customer: NewCustomer, BOOLEAN

  • 1 mark

    15.75 / The deposit paid by the customer: Deposit, REAL

1b · 4 marks

  • 1 mark

    (Total * DepRate) + 1.5 evaluates to 249.50

  • 1 mark

    RIGHT(Description, 7) evaluates to "(small)"

  • 1 mark

    (LENGTH(Description) - 8) > 16 evaluates to TRUE

  • 1 mark

    NUM_TO_STR(INT(DepRate * 10)) & '%' evaluates to "20%"

1c · 3 marks

  • 1 mark

    Declare a composite / record (type)

  • 1 mark

    Declare an array of the given composite / record (type)

  • 1 mark

    … containing all data items required // containing items of different data types

2a · 5 marks

  • 1 mark

    Initialise Total to zero

  • 1 mark

    Check for only first input of 27 in a loop then attempt to sum values

  • 1 mark

    Loop until 0 input

  • 1 mark

    Sum values input (after input of first 27) in a loop

  • 1 mark

    Output Total after a reasonable attempt

2b · 2 marks

  • 1 mark

    Name: (pre / post) conditional loop

  • 1 mark

    Justification: the number of iterations is not known // loop ends following a specific input (in the loop)

3a · 5 marks

  • 1 mark

    Start_Pointer value (4)

  • 1 mark

    Row 2 (D11, 3)

  • 1 mark

    Rows 3 and 4 (D100, 0 and D40, 1)

  • 1 mark

    Row 5 (F1, 6)

  • 1 mark

    Rows 7 and 8 (F3, 8 and F4, 0)

3b · 4 marks

  • 1 mark

    Assign the data item D6 to F1

  • 1 mark

    Set the pointer of this node to point to D11

  • 1 mark

    Set Ptr2 to point to F2

  • 1 mark

    Set pointer of D32 to point to D6

4a · 6 marks

  • 1 mark

    Procedure heading and ending

  • 1 mark

    Local COdd, CEven and ThisNum declared as integers

  • 1 mark

    Conditional loop while ThisNum <> 99

  • 1 mark

    Input ThisNum in a loop

  • 1 mark

    Check ThisNum is odd or even in a loop

  • 1 mark

    Increment appropriate count in a loop, both counts must have been initialised before loop

4b · 3 marks

  • 1 mark

    data set with (only) odd values, terminated with 99

  • 1 mark

    data set with (only) even values, terminated with 99

  • 1 mark

    data sets with same number of odd and even values, terminated with 99

5 · 6 marks

  • 1 mark

    Initialisation row

  • 1 mark

    Iteration Count = 1 with correct Index, Count and array Mix as shown

  • 1 mark

    Iteration Count = 2 with correct Index, Count and array Mix as shown

  • 1 mark

    Iteration Count = 3 with correct Index, Count and array Mix as shown

  • 1 mark

    Iteration Count = 4 with correct Index, Count and array Mix as shown

  • 1 mark

    Final iteration, Count = 5, correct Index, Count and array Mix as shown plus Mix[4] assignment

6a · 6 marks

  • 1 mark

    Procedure heading, including parameters, and ending

  • 1 mark

    Loop for NumFiles iterations

  • 1 mark

    Attempt to create filename suffix using NUM_TO_STR() in a loop

  • 1 mark

    Completely correct filename

  • 1 mark

    OPENFILE in WRITE mode and subsequent CLOSE in a loop

  • 1 mark

    WRITE initial first line to the file in a loop

6b(i) · 1 mark

  • 1 mark

    Function

6b(ii) · 1 mark

  • 1 mark

    FUNCTION CheckFiles(NameRoot : STRING) RETURNS INTEGER

6b(iii) · 1 mark

  • 1 mark

    Read

7a · 4 marks

  • 1 mark

    Module names

  • 1 mark

    Parameters with labels to Module-X and between Module-X and Reset

  • 1 mark

    Parameter (with label) to Module-Z and return from Module-Z

  • 1 mark

    Parameters with labels to Module-Y and Restore and return values from Module-Y

7b · 2 marks

  • 1 mark

    Reference to selection

  • 1 mark

    Naming all four modules correctly

8a · 7 marks

  • 1 mark

    Function heading and ending including parameter and return type

  • 1 mark

    Convert parameter to a number

  • 1 mark

    (Conditional) loop through array // Skip all unused elements

  • 1 mark

    Skip unused element in a loop // Attempt to check one range

  • 1 mark

    Attempt to check one range with destination in a loop // Check two ranges with destination correctly

  • 1 mark

    Test all ranges correctly with destination in a loop // Check all ranges with destination correctly

  • 1 mark

    Store port value if destination matched in a loop (and exit loop) / Store port value if destination matched

8b · 7 marks

  • 1 mark

    Ignore message if data field is empty

  • 1 mark

    Extract ThisDest from ThisMsg

  • 1 mark

    Test if destination is this computer

  • 1 mark

    Attempt to use StackMsg()

  • 1 mark

    Fully correct use of StackMsg()for both cases / stacks

  • 1 mark

    Test StackMsg() return value for both cases

  • 1 mark

    Following a reasonable attempt at MP6 output warning if StackMsg() returns FALSE

8c(i) · 3 marks

  • 1 mark

    Point 1 of selected scenario

  • 1 mark

    Point 2 of selected scenario

  • 1 mark

    Point 3 of selected scenario

8c(ii) · 1 mark

  • 1 mark

    Queue

Questions

  1. 1
    Question 111 marks
    Mark scheme ›
  2. 2
    Question 27 marks
    Mark scheme ›
  3. 3
    Question 39 marks
    Mark scheme ›
  4. 4
    Question 49 marks
    Mark scheme ›
  5. 5
    Question 56 marks
    Mark scheme ›
  6. 6
    Question 69 marks
    Mark scheme ›
  7. 7
    Question 76 marks
    Mark scheme ›
  8. 8
    Question 818 marks
    Mark scheme ›

More 9618 papers

Other papers from Oct/Nov 2023

Solve it on ExamPalStart