A Level Computer Science 9618 Paper 21, 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/21 · May/June 2024

Download PDF
1

Refer to the insert for the list of pseudocode functions and operators. 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(i)

The variable names A, B, C and D in part (a) are not good programming practice. State why these variable names are not suitable.

[1]
c(ii)

Identify one problem that these variable names might cause.

[1]
c(iii)

The choice of suitable variable names is one example of good programming practice. Give one other example.

[1]
2

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.

Figure 1 of 3 for question 2
Figure 2 of 3 for question 2
Figure 3 of 3 for question 2
a

Complete the program flowchart.

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

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.

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

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

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")

[6]
b(i)

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. Write the single line of pseudocode.

[1]
b(ii)

State where this new line should be placed.

[1]
6

Three points on a grid form a triangle with sides of length A, B and C as shown in the example: [diagram] 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: [diagram] 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

Figure 1 of 2 for question 6
Figure 2 of 2 for question 6
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]
7

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.

Figure 1 of 1 for question 7
a(i)

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. State one advantage of applying abstraction to this problem.

[1]
a(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]
a(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(i)

The structure chart illustrates part of the membership program: [structure chart] Data item notes: • Name contains the name of a club member • P1 and T1 are of type real. Explain the meaning of the diamond symbol (labelled with the letter A) in the chart.

[2]
b(ii)

Write the pseudocode module headers for Sub-A and Sub-B. Sub-A ........................................................................................................................................... ........................................................................................................................................... Sub-B ........................................................................................................................................... ...........................................................................................................................................

[4]
8

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

9618/21 · May/June 2024

Download PDF

1a · 4 marks

  • 1 mark

    Row 1: CHAR / STRING

  • 1 mark

    Row 2: INTEGER / REAL

  • 1 mark

    Row 3: REAL

  • 1 mark

    Row 4: STRING

1b · 4 marks

  • 1 mark

    Row 1: TRUE

  • 1 mark

    Row 2: 1

  • 1 mark

    Row 3: 'a' // "a"

  • 1 mark

    Row 4: TRUE

1c(i) · 1 mark

  • 1 mark

    The names do not reflect / indicate the purpose of the variable // the names are not meaningful

1c(ii) · 1 mark

  • 1 mark

    They make the program more difficult to understand / debug / maintain

1c(iii) · 1 mark

  • 1 mark

    Indentation / use of white space // Capitalisation of keywords // Use of comments // Use of modular programming // Use of local variables

2a · 5 marks

  • 1 mark

    Initialise both counts

  • 1 mark

    Increment Tries every time a pair is input

  • 1 mark

    Compare A > B and increment Count if TRUE

  • 1 mark

    Test for Count = 10 (10th time A > B) – MUST include Yes / No labels

  • 1 mark

    If so output Tries, otherwise loop

2b · 2 marks

  • 1 mark

    A (variable of type) string will be input // by example e.g. “67,72”

  • 1 mark

    A special / identified character would need to be used to separate each numeric value // all numbers are fixed length

3a · 3 marks

  • 1 mark

    The PS contains a null pointer

  • 1 mark

    The PF points to the first element on the free list

  • 1 mark

    All the nodes are on the free list

3b · 5 marks

  • 1 mark

    Variables: The two variables will be of type Integer

  • 1 mark

    Variables: 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

  • 1 mark

    Variables: Third valid point from first three rows (if applicable, up to Max 2 marks for 'Variables')

  • 1 mark

    One mark for both Array 1 rows: The first 1D array will be of type String AND The first 1D array will be used to store the values // data items // User IDs

  • 1 mark

    One mark for both Array 2 rows: The second 1D array will be of type Integer AND The second 1D array will be used to store the pointers // point to next item

4 · 6 marks

  • 1 mark

    Function heading, ending and return type

  • 1 mark

    Declare local variables Odd, Even and Index as integers

  • 1 mark

    Initialise Odd and Even

  • 1 mark

    Loop for 100 iterations // through array

  • 1 mark

    Sum Odd and Even element values in a loop

  • 1 mark

    Compare Odd and Even after the loop and Return appropriate string

5a · 6 marks

  • 1 mark

    Zone 1 (Count column: 1, 3, 5)

  • 1 mark

    Zone 2 (C column: 'X', 'Y', 'W')

  • 1 mark

    Zone 3 (L and Index columns: 3, 1 / 2, 2 / 4, 3)

  • 1 mark

    Zone 4 (Result and Data initialisation and first row updates: "*****", "aaaaaa", "bbbbbb", "cccccc", "AAAAAA", "AAA")

  • 1 mark

    Zone 5 (Result and Data second row updates: "bbbbbb", "bb")

  • 1 mark

    Zone 6 (Result and Data third row updates: "bbbb")

5b(i) · 1 mark

  • 1 mark

    OTHERWISE : CALL Error(C)

5b(ii) · 1 mark

  • 1 mark

    After the 'Z' clause in the CASE construct // before the ENDCASE

6a · 6 marks

  • 1 mark

    Calculate the square of the length of at least one side

  • 1 mark

    Calculation of all three lengths squared correctly

  • 1 mark

    One correct comparison of square of three lengths

  • 1 mark

    All three comparisons…

  • 1 mark

    combined using logical operators / nested IF // completely correct selection

  • 1 mark

    Return result correctly in both cases

6b · 2 marks

  • 1 mark

    Problem: The function will return an incorrect value // the test will fail

  • 1 mark

    Solution: Round the calculated values (to a known number of decimal places) // Define a threshold below which any difference can be ignored

7a(i) · 1 mark

  • 1 mark

    To make the solution easier to design / implement / solve

7a(ii) · 3 marks

  • 1 mark

    Item: mobile phone number Justification: to send the text message

  • 1 mark

    Item: name Justification: to personalise the text message

  • 1 mark

    Item: exercise interest Justification: to determine whether this member would be interested

7a(iii) · 2 marks

  • 1 mark

    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

  • 1 mark

    A second example from the list

7b(i) · 2 marks

  • 1 mark

    reference to selection / decision / if

  • 1 mark

    naming all four modules correctly

7b(ii) · 4 marks

  • 1 mark

    PROCEDURE in Sub-A header

  • 1 mark

    Name : STRING and BYREF P2 : BOOLEAN in Sub-A header

  • 1 mark

    FUNCTION in Sub-B header

  • 1 mark

    (P1 : REAL) and RETURNS REAL in Sub-B header

8a · 8 marks

  • 1 mark

    Loop to length of Line (parameter) // length of Line -1

  • 1 mark

    Terminate loop on first double slash

  • 1 mark

    Attempt to extract one/two characters in a loop

  • 1 mark

    Check for "//" after attempt at extraction in a loop

  • 1 mark

    Record start position of comment // Calculate amount of trim required

  • 1 mark

    Attempt to trim Line from start of comment

  • 1 mark

    Completely correct trimmed Line from start of comment

  • 1 mark

    Return Line after a reasonable overall attempt

8b · 7 marks

  • 1 mark

    Generate filenames condone missing “_”

  • 1 mark

    Open both files in correct modes and subsequently close

  • 1 mark

    Loop to EOF(OldFile)

  • 1 mark

    Read a line from OldFile and execute DeleteComment()in a loop

  • 1 mark

    Skip blank lines after DeleteComment()in a loop

  • 1 mark

    Write Line to stage 1 file and increment Count

  • 1 mark

    Return the number of lines after a reasonable attempt at counting

Questions

  1. 1
    Question 111 marks
    Mark scheme ›
  2. 2
    Question 27 marks
    Mark scheme ›
  3. 3
    Question 38 marks
    Mark scheme ›
  4. 4
    Question 46 marks
    Mark scheme ›
  5. 5
    Question 58 marks
    Mark scheme ›
  6. 6
    Question 68 marks
    Mark scheme ›
  7. 7
    Question 712 marks
    Mark scheme ›
  8. 8
    Question 815 marks
    Mark scheme ›

More 9618 papers

Other papers from May/June 2024

Solve it on ExamPalStart