A Level Computer Science 9618 Paper 23, May/June 2024

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 · May/June 2024

Download PDF
1

Refer to the insert for the list of pseudocode functions and operators. 1 A program uses many complex algorithms. One algorithm is repeated in several places. The code for the algorithm is the same wherever it is used, but the calculations within the algorithm may operate on different data. The result of each calculation is used by the code that follows it. It is decided to modify the program and implement the algorithm as a separate module.

a(i)

State two benefits of this modification to the existing program. 1 ........................................................................................................................................ ........................................................................................................................................... 2 ........................................................................................................................................ ...........................................................................................................................................

[2]
a(ii)

Describe how the modification would be implemented.

[3]
b

Four of the expressions used in the program are represented by pseudocode in the table. Complete each pseudocode expression with a function or operator so that it evaluates to the value shown. Any functions and operators used must be defined in the insert.

Pseudocode expressionEvaluates to
........................................ ("Random", 2, 3)"and"
5 + ........................................ (10/11/2023)15
........................................ ("45000")TRUE
(20 ........................................ 3) + 13
[4]
2
a

A program uses a global 1D array of type string and a text file. An algorithm that forms part of the program is expressed as follows: • copy the first line from the file into the first element of the array • copy the second line from the file into the second element of the array • continue until all lines in the file have been copied into the array. Stepwise refinement is applied to the algorithm. Outline five steps for this algorithm that could be used to produce pseudocode. Assume there are more elements in the array than lines in the file. Do not use pseudocode statements in your answer. Step 1 ....................................................................................................................................... ................................................................................................................................................... Step 2 ....................................................................................................................................... ................................................................................................................................................... Step 3 ....................................................................................................................................... ................................................................................................................................................... Step 4 ....................................................................................................................................... ................................................................................................................................................... Step 5 ....................................................................................................................................... ...................................................................................................................................................

[5]
b

Sequence is one programming construct. Identify one other programming construct that will be required when the algorithm from part (a) is converted into pseudocode and explain its use. Construct .................................................................................................................................. ................................................................................................................................................... Use ........................................................................................................................................... ...................................................................................................................................................

[2]
3

A record structure is declared to hold data relating to components being produced in a factory: TYPE Component DECLARE Item_ID : STRING DECLARE Reject : BOOLEAN DECLARE Weight : REAL ENDTYPE The factory normally produces a batch (or set) of 1000 components at a time. A global array is declared to store 1000 records for a batch: DECLARE Batch : ARRAY [1:1000] OF Component Two global variables contain the minimum and maximum acceptable weight for each component. The values represent an inclusive range and are declared as: DECLARE Min, Max : REAL

Figure 1 of 3 for question 3
Figure 2 of 3 for question 3
Figure 3 of 3 for question 3
a(i)

A program uses a variable ThisIndex as the array index to access a record. Write a pseudocode clause to check whether or not the weight of an individual component is within the acceptable range.

[3]
a(ii)

When batches of less than 1000 components are processed, it is necessary to indicate that certain elements in the array are unused. Suggest how an unused array element could be indicated.

[1]
b

A module InRange() will: • be called with an integer parameter representing an index value of a record in the Batch array • check if the weight of the indexed component is within the acceptable range • return TRUE if the weight is in the range and FALSE if it is not. A module BatchCheck() will: • iterate through a batch of 1000 component records • call module InRange() to check each individual component record • keep a count of the number of components that fail • output a suitable warning message and immediately stop if the number of failed components exceeds 5. Complete the program flowchart to represent the algorithm for module BatchCheck().

[5]
4

A procedure TwoParts() will input a sequence of real values, one at a time. The procedure will: • process the sequence in two parts • form a first total by adding the values until the first zero • form a second total by adding the values after the first zero until the second zero • output the average of the two totals, together with a suitable message. Values input in the first part are totalled using global variable TotalA and those input in the second part are totalled using global variable TotalB.

a

Write pseudocode for the procedure TwoParts().

[6]
b(i)

The value zero denotes the split between the two parts of the sequence. The requirement changes and now there may be up to 20 parts. Identify a suitable data structure that could be used to store the different total values.

[2]
b(ii)

Describe three benefits of using the data structure given in part (b)(i). 1 ........................................................................................................................................ ........................................................................................................................................... 2 ........................................................................................................................................ ........................................................................................................................................... 3 ........................................................................................................................................ ...........................................................................................................................................

[3]
5

A program is being designed in pseudocode. The program contains the following declaration: DECLARE Data : ARRAY[1:1000] OF STRING A procedure ArrayInitialise() is written to initialise the values in the array: PROCEDURE ArrayInitialise(Label : STRING) DECLARE Index : INTEGER Index ← 1 WHILE Index <= 1000 CASE OF (Index MOD 2) 0 : Data[Index] ← FormatA(Label) Index ← Index + 1 1 : Data[Index] ← FormatB(Label) Index ← Index + 1 ENDCASE ENDWHILE ENDPROCEDURE Functions FormatA() and FormatB() apply fixed format case changes to the parameter string.

a

The design of the procedure does not use the most appropriate loop construct. Suggest a more appropriate construct that could be used and explain your choice. Construct .................................................................................................................................. Explanation ............................................................................................................................... ...................................................................................................................................................

[2]
b

The algorithm calls one of the functions FormatA() and FormatB() each time within the loop. Explain why this is not efficient and suggest a more efficient solution.

[4]
6

A program displays a progress bar to inform the user of the progress of tasks that take a significant time to complete, such as those involving file transfer operations. Task progress is divided into 11 steps. Each step represents the amount of progress as a percentage. An image is associated with each step and each image is stored in a different file. Different progress bar images may be selected. For a given image, files all have the same filename root, with a different suffix. The table illustrates the process for using the image with filename root BargraphA

StepPercentage progressImage filenameImage
1< 10BargraphA-1.bmp
2>= 10 and < 20BargraphA-2.bmp
3>= 20 and < 30BargraphA-3.bmp
9>= 80 and < 90BargraphA-9.bmp
10>= 90 and < 100BargraphA-10.bmp
11100BargraphA-11.bmp

A procedure Progress() will: • be called with two parameters: ○ an integer representing the percentage progress (0 to 100 inclusive) ○ a string representing the image filename root • generate the full image filename • call a procedure Display() using the full image filename as the parameter.

Figure 1 of 2 for question 6
Figure 2 of 2 for question 6
a

Write pseudocode for procedure Progress().

[6]
b(i)

The definition of procedure Progress() is provided here for reference: A procedure Progress() will: • be called with two parameters: ○ an integer representing the percentage progress (0 to 100 inclusive) ○ a string representing the image filename root • generate the full image filename • call a procedure Display() using the full image filename as the parameter. Progress() will be rewritten and a new module Progress2() produced with these requirements: • an additional parameter of type integer will specify the total number of steps • the image filename will be returned (procedure Display() will not be called from within Progress2()). Write pseudocode for the new module header.

[2]
b(ii)

State one benefit of increasing the number of steps.

[1]
7

Seven program modules form part of a program. A description of the relationship between the modules is summarised below. Any return values are stated in the description.

Module nameDescription
Mod-Acalls Mod-B followed by Mod-C
Mod-B• called with parameters Par1 and Par2<br>• calls either Mod-D or Mod-E, determined when the program runs<br>• returns a Boolean value
Mod-C• called with parameters Par1 and Par3<br>• Par3 is passed by reference<br>• repeatedly calls Mod-F followed by Mod-G
Mod-Dcalled with parameter Par2
Mod-E• called with parameter Par3<br>• returns an integer value
Mod-Fcalled with parameter Par3
Mod-G• called with parameter Par3<br>• Par3 is passed by reference

Parameters in the table are as follows: • Par1 and Par3 are of type string. • Par2 is of type integer.

a(i)

Identify the modules that would be implemented as functions.

[1]
a(ii)

Modules Mod-F and Mod-G are both called with Par3 as a parameter. In the case of Mod-F, the parameter is passed by value. In the case of Mod-G, the parameter is passed by reference. Explain the effect of the two different ways of passing the parameter Par3.

[2]
b

Draw a structure chart to show the relationship between the seven modules and the parameters passed between them.

[6]
8

A teacher is designing a program to process pseudocode projects written by her students. The program analyses a student project and extracts information about each module that is defined (each procedure or function). This information is stored in a global 2D array ModInfo of type string. A module header is the first line of a module definition and starts with either of the keywords PROCEDURE or FUNCTION. An example of part of the array is given below. Row 10 of the array shows that a procedure header occurs on line 27 and row 11 shows that a function header occurs on line 35. "P" represents a procedure and "F" represents a function:

x = 1x = 2x = 3
ModInfo[10, x]"27""P""MyProc(Z : CHAR)"
ModInfo[11, x]"35""F""MyFun(Y : CHAR) RETURNS BOOLEAN"

The string stored in column 3 is called the module description. This is the module header without the keyword. A valid module header will: • be at least 13 characters long • start with the keyword PROCEDURE or FUNCTION. The keyword may appear in either upper or lower case (or a mix of both) and must be followed by a space character. The teacher has defined the first program module as follows:

ModuleDescription
Header()• called with a parameter of type string representing a line of pseudocode<br>• if the line is a valid procedure header, returns a string:<br>&nbsp;&nbsp;&nbsp;&nbsp;"P<Module description>"<br>• if the line is a valid function header, returns a string:<br>&nbsp;&nbsp;&nbsp;&nbsp;"F<Module description>"<br>• otherwise, returns an empty string

For example, given the string: "FUNCTION Zap(X : INTEGER) RETURNS CHAR" Header() returns the string: "FZap(X : INTEGER) RETURNS CHAR"

a

Write pseudocode for module Header().

[7]
b

A new module is required:

ModuleDescription
FindModules()• called with a parameter of type string representing a student project file name<br>• uses module Header() to check each line of the project<br>• assigns values to the ModInfo array for each module declaration in the student project

As a reminder, the previous example of part of the array is repeated below:

x = 1x = 2x = 3
ModInfo[10, x]"27""P""MyProc(Z : CHAR)"
ModInfo[11, x]"35""F""MyFun(Y : CHAR) RETURNS BOOLEAN"

Write pseudocode for module FindModules(). Assume that the array contains enough rows for the number of modules in each project.

[8]

Mark scheme

9618/23 · May/June 2024

Download PDF

1a(i) · 2 marks

  • 1 mark

    The code can be called when needed

  • 1 mark

    Any subsequent change to the algorithm / calculation needs to be made once only // Easier to manage / maintain (the program) // Less code / no code duplication // The algorithm / code / calculation can be designed / coded / tested once

1a(ii) · 3 marks

  • 1 mark

    Create a module / function / procedure / subroutine using the (old) code / algorithm

  • 1 mark

    Replace the old code / algorithm wherever it appears with a call to the module / function / procedure / subroutine

  • 1 mark

    Pass the data as parameter(s) // Use of global variable(s) // Return the result (of the calculation) // Assign result to global variable(s) / BYREF parameter(s) // Create local variables as needed (to perform the calculation)

1b · 4 marks

  • 1 mark

    MID("Random", 2, 3) evaluates to "and"

  • 1 mark

    5 + DAY(10/11/2023) evaluates to 15

  • 1 mark

    IS_NUM("45000") evaluates to TRUE

  • 1 mark

    (20 MOD 3) + 1 evaluates to 3

2a · 5 marks

  • 1 mark

    Open the file (in read mode and subsequently close)

  • 1 mark

    Initialise an index variable (to 1 // 0)

  • 1 mark

    Repeat (the next three steps) until the end of file is reached

  • 1 mark

    Read a line from the file (into a string variable)

  • 1 mark

    Store the line / variable in the array at the index // Increment the index in a loop

2b · 2 marks

  • 1 mark

    Construct: a conditional loop // a selection statement

  • 1 mark

    Use: To keep repeating until the end of the file is reached // To test / check the value returned by the EOF() function

3a(i) · 3 marks

  • 1 mark

    Reference to Batch[ThisIndex].Weight

  • 1 mark

    A valid check for one boundary

  • 1 mark

    A valid check for other boundary with correct logic operator

3a(ii) · 1 mark

  • 1 mark

    Set the Item_ID field to an empty string / NULL / invalid value // Set Weight to <= 0 / zero

3b · 5 marks

  • 1 mark

    Zone 1: Set Index to 0, Set Count to 0

  • 1 mark

    Zone 2: Set Index to Index + 1, Is Index = 1001?

  • 1 mark

    Zone 3: Is InRange(Index) = TRUE?

  • 1 mark

    Zone 4: Set Count to Count + 1

  • 1 mark

    Zone 5: Is Count > 5?, OUTPUT "Reject Batch"

4a · 6 marks

  • 1 mark

    Procedure heading and ending

  • 1 mark

    Declare all local variables

  • 1 mark

    Initialise TotalA and TotalB

  • 1 mark

    First conditional loop until zero entered, summing TotalA // Loop until both parts (sequences) have been entered

  • 1 mark

    Second conditional loop until zero entered, summing TotalB // Loop summing appropriate Totals

  • 1 mark

    Calculation of average and output with a message // Calculation of the average for the values making up the two totals and both output with a suitable message

4b(i) · 2 marks

  • 1 mark

    array

  • 1 mark

    20 reals

4b(ii) · 3 marks

  • 1 mark

    (Multiple instances referenced via a single identifier so) fewer identifiers needed

  • 1 mark

    Easier to process / search / organise / access the data // Values may be accessed via a loop-controlled variable /an index //An array / data can be iterated through

  • 1 mark

    Makes the program/algorithm easier to write / design / understand / maintain / modify // Simplifies the program // Easier to debug / test

5a · 2 marks

  • 1 mark

    Count-controlled loop

  • 1 mark

    the number of iterations is known

5b · 4 marks

  • 1 mark

    The functions will return the same value every time they are called

  • 1 mark

    ... because Label / the parameter value does not change within the loop

  • 1 mark

    Assign FormatA(Label) and FormatB(Label) to two (local) variables before the loop

  • 1 mark

    Use the (new) variables in place of the function calls / in the loop // Replace the references to FormatA() and FormatB() in the CASE clauses with the new variable names

6a · 6 marks

  • 1 mark

    Procedure heading, parameters and ending

  • 1 mark

    Calculate StepValue as integer value // Attempt at calculating file number // Correct selection construct(s) structure

  • 1 mark

    Add 1 to obtain file number // Completely correct file number calculation // Use of selection statement to obtain two file numbers

  • 1 mark

    Use of NUM_TO_STR() to convert file number to string and use // Use of selection statement to obtain all the file numbers

  • 1 mark

    Concatenate Root, hyphen, file number and ".bmp" suffix

  • 1 mark

    Call Display() with filename as parameter following a reasonable attempt / once with filename as parameter following a reasonable attempt

6b(i) · 2 marks

  • 1 mark

    Keyword FUNCTION Progress2 and three parameters of correct type

  • 1 mark

    Keyword RETURNS and type string

6b(ii) · 1 mark

  • 1 mark

    The progress display will more accurately show the progress of the task

7a(i) · 1 mark

  • 1 mark

    Mod-B() and Mod-E()

7a(ii) · 2 marks

  • 1 mark

    1 mark for a reasonable attempt to explain

  • 1 mark

    2 marks for full explanation including context (any change made to the parameter value / Par3 within Mod-G() is reflected in the (subsequent) value in the calling module / Mod-C() (after Mod-G() terminates) AND any change made to the parameter value / Par3 within Mod-F() is NOT reflected in the (subsequent) value in the calling module / Mod-C() (after Mod-F() terminates))

7b · 6 marks

  • 1 mark

    All modules correctly labelled and interconnected

  • 1 mark

    Parameters between Mod-A and Mod-B and return value from Mod-B

  • 1 mark

    Parameters between Mod-A and Mod-C

  • 1 mark

    Diamond applied to Mod-B only

  • 1 mark

    Iteration arrow applied to Mod-C only

  • 1 mark

    All parameters at lower level and return value

8a · 7 marks

  • 1 mark

    Function heading, parameter, return type and ending

  • 1 mark

    Check that the line is at least 13 characters long before attempting to extract and return empty string

  • 1 mark

    Attempt at: Extract characters, 9 or 10 characters, corresponding to keyword plus space and compare with appropriate keyword plus space

  • 1 mark

    Completely correct MP3

  • 1 mark

    Use of type case conversion to allow for 'any case'

  • 1 mark

    Calculation of 'rest of line' and concatenation with 'P or 'F'

  • 1 mark

    Return string

8b · 8 marks

  • 1 mark

    Open file in READ mode and subsequently close

  • 1 mark

    Loop to EOF(FileName)

  • 1 mark

    Read a line from the file and maintain LineNum in a loop

  • 1 mark

    Call Header() and use return value in a loop

  • 1 mark

    Test return value for "" in a loop

  • 1 mark

    Attempt at all three-array assignment for all columns in correct row

  • 1 mark

    Correct values assigned to all columns of array

  • 1 mark

    Maintain correct array row index

Questions

  1. 1
    Question 19 marks
    Mark scheme ›
  2. 2
    Question 27 marks
    Mark scheme ›
  3. 3
    Question 39 marks
    Mark scheme ›
  4. 4
    Question 411 marks
    Mark scheme ›
  5. 5
    Question 56 marks
    Mark scheme ›
  6. 6
    Question 69 marks
    Mark scheme ›
  7. 7
    Question 79 marks
    Mark scheme ›
  8. 8
    Question 815 marks
    Mark scheme ›

More 9618 papers

Other papers from May/June 2024

Solve it on ExamPalStart