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

Question paper and mark scheme75 marks3 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/41 · Oct/Nov 2023

Download PDF
1

This iterative pseudocode algorithm for the function IterativeVowels() takes a string as a parameter and counts the number of lower-case vowels in this string. The vowels are the letters a, e, i, o and u. FUNCTION IterativeVowels(Value : STRING) RETURNS INTEGER DECLARE Total : INTEGER DECLARE LengthString : INTEGER DECLARE FirstCharacter : CHAR Total ← 0 LengthString ← LENGTH(Value) FOR X ← 0 TO LengthString - 1 FirstCharacter ← MID(Value, 0, 1) IF FirstCharacter = 'a' OR FirstCharacter = 'e' OR FirstCharacter = 'i' OR FirstCharacter = 'o' OR FirstCharacter = 'u' THEN Total ← Total + 1 ENDIF Value ← MID(Value, 1, LENGTH(Value)-1) NEXT X RETURN Total ENDFUNCTION The pseudocode function MID(X, Y, Z) returns Z number of characters from string X, starting at the character in position Y. The first character in a string is in position 0, for example: MID("computer", 0, 3) returns "com" The pseudocode function LENGTH(X) returns the number of characters in the string X, for example: LENGTH("computer") returns 8

a(i)

Write program code for the function IterativeVowels(). Save your program as Question1_N23. Copy and paste the program code into part 1(a)(i) in the evidence document.

[5]
a(ii)

Write program code to call the function IterativeVowels() with the parameter "house" from the main program. Output the return value. Save your program. Copy and paste the program code into part 1(a)(ii) in the evidence document.

[2]
a(iii)

Test your program. Take a screenshot of the output. Save your program. Copy and paste the screenshot into part 1(a)(iii) in the evidence document.

[1]
b(i)

Rewrite the function IterativeVowels() as a recursive function with the identifier RecursiveVowels(). Save your program. Copy and paste the program code into part 1(b)(i) in the evidence document.

[6]
b(ii)

Write program code to call the function RecursiveVowels() with the parameter "imagine" from the main program. Output the return value. Save your program. Copy and paste the program code into part 1(b)(ii) in the evidence document.

[1]
b(iii)

Test your program. Take a screenshot of the output. Save your program. Copy and paste the screenshot into part 1(b)(iii) in the evidence document.

[1]
2

A linear queue is implemented using the 1D array, Queue. The index of the first element in the array is 0.

a(i)

Write program code to declare: • Queue — a global array with space to store 50 IDs of type string • HeadPointer — a global variable to point to the first element in the queue, initialised to −1 • TailPointer — a global variable to point to the next available space in the queue, initialised to 0. Save your program as Question2_N23. Copy and paste the program code into part 2(a)(i) in the evidence document.

[2]
a(ii)

The procedure Enqueue() takes a string parameter. If the queue is full, the procedure outputs a suitable message. If the queue is not full, the procedure inserts the parameter into the queue and updates the relevant pointer(s). Write program code for Enqueue(). Save your program. Copy and paste the program code into part 2(a)(ii) in the evidence document.

[4]
a(iii)

The function Dequeue() checks if the queue is empty. If the queue is empty, the function outputs a suitable message and returns the string "Empty". If the queue is not empty, the function returns the first element in the queue and updates the relevant pointer(s). Write program code for Dequeue(). Save your program. Copy and paste the program code into part 2(a)(iii) in the evidence document.

[4]
b

A shop sells computer games. Each game has a unique identifier (ID) of string data type. The text file QueueData.txt contains a list of game IDs. The procedure ReadData() reads the data from the text file and inserts each item of data into the array Queue. Write program code for the procedure ReadData(). Save your program. Copy and paste the program code into part 2(b) in the evidence document.

[6]
c(i)

Some game IDs appear in the text file more than once. The program needs to total the number of times each game ID appears in the text file. The record structure RecordData has the following fields: • ID — a string to store the game ID • Total — an integer to store the total number of times that game ID appears in the text file. Write program code to declare the record structure RecordData. If you are writing in Python, include attribute declarations as comments. Save your program. Copy and paste the program code into part 2(c)(i) in the evidence document.

[2]
c(ii)

The global 1D array Records stores up to 50 items of type RecordData. The global variable NumberRecords stores the number of records currently in the array Records and is initialised to 0. Write program code to declare Records and NumberRecords. If you are writing in Python, include attribute declarations as comments. Save your program. Copy and paste the program code into part 2(c)(ii) in the evidence document.

[2]
c(iii)

The pseudocode algorithm for the procedure TotalData(): • uses Dequeue() to remove an ID from the queue • checks whether a RecordData with the returned ID exists in Records • increments the total for that ID in the record if the ID already exists • creates a new record and stores it in Records if the ID does not exist. PROCEDURE TotalData() DECLARE DataAccessed : STRING DECLARE Flag : BOOLEAN DataAccessed ← Dequeue() Flag ← FALSE IF NumberRecords = 0 THEN Records[NumberRecords].ID ← DataAccessed Records[NumberRecords].Total ← 1 Flag ← TRUE NumberRecords ← NumberRecords + 1 ELSE FOR X ← 0 TO NumberRecords - 1 IF Records[X].ID = DataAccessed THEN Records[X].Total ← Records[X].Total + 1 Flag ← TRUE ENDIF NEXT X ENDIF IF Flag = FALSE THEN Records[NumberRecords].ID ← DataAccessed Records[NumberRecords].Total ← 1 NumberRecords ← NumberRecords + 1 ENDIF ENDPROCEDURE Write program code for the procedure TotalData(). Save your program. Copy and paste the program code into part 2(c)(iii) in the evidence document.

[5]
d

The procedure OutputRecords() outputs the ID and total of each record in Records in the format: ID 1234 Total 4 Write program code for OutputRecords(). Save your program. Copy and paste the program code into part 2(d) in the evidence document.

[1]
e(i)

The main program needs to: • call ReadData() • call TotalData() for each element in the queue • call OutputRecords(). Write program code for the main program. Save your program. Copy and paste the program code into part 2(e)(i) in the evidence document.

[2]
e(ii)

Test your program. Take a screenshot of the output. Save your program. Copy and paste the screenshot into part 2(e)(ii) in the evidence document.

[1]
3

A computer game is written using object-oriented programming. The game has multiple characters that can move around the screen. The class Character stores data about the characters. Each character has a name, a current X (horizontal) position and a current Y (vertical) position. Character Name : STRING - stores the name of the character as a string XPosition : INTEGER - stores the X position as an integer YPosition : INTEGER - stores the Y position as an integer Constructor() - initialises Name, XPosition and YPosition to its parameter values GetXPosition() - returns the X position GetYPosition() - returns the Y position SetXPosition() - adds the parameter to the X position validates that the new X position is between 0 and 10000 inclusive SetYPosition() - adds the parameter to the Y position validates that the new Y position is between 0 and 10000 inclusive Move() - takes a direction as a parameter and calls either SetXPosition or SetYPosition with an integer value

a(i)

Write program code to declare the class Character and its constructor. Do not declare the other methods. Use your programming language’s appropriate constructor. If you are writing in Python, include attribute declarations using comments. Save your program as Question3_N23. Copy and paste the program code into part 3(a)(i) in the evidence document.

[4]
a(ii)

The get methods GetXPosition() and GetYPosition() each return the relevant attribute. Write program code for the get methods. Save your program. Copy and paste the program code into part 3(a)(ii) in the evidence document.

[3]
a(iii)

The set methods SetXPosition() and SetYPosition() each take a value as a parameter and add this to the current X or Y position. If the new value exceeds 10000, it is limited to 10000. If the new value is below 0, it is limited to 0. Write program code for the set methods. Save your program. Copy and paste the program code into part 3(a)(iii) in the evidence document.

[4]
a(iv)

The method Move() takes a string parameter: "up", "down", "left" or "right". The table shows the change each direction will make to the X or Y position. Use the appropriate method to change the position value. Direction | Value change up | Y position + 10 down | Y position − 10 left | X position − 10 right | X position + 10 Write program code for Move(). Save your program. Copy and paste the program code into part 3(a)(iv) in the evidence document.

[4]
b

Write program code to declare a new instance of Character with the identifier Jack. The starting X position is 50 and the starting Y position is 50, the character’s name is Jack. Save your program. Copy and paste the program code into part 3(b) in the evidence document.

[2]
c(i)

The class BikeCharacter inherits from the class Character. BikeCharacter Constructor() - takes Name, XPosition and YPosition as parameters calls its parent class constructor with the appropriate values Move() - overrides the method Move() from the parent class by changing either the X position or the Y position by 20 instead of 10 Write program code to declare the class BikeCharacter and its constructor. Do not declare the other method. Use your programming language’s appropriate constructor. If you are writing in Python, include attribute declarations using comments. Save your program. Copy and paste the program code into part 3(c)(i) in the evidence document.

[3]
c(ii)

The method Move() overrides the method from the parent class. The table shows the change each direction will make to the X or Y position. Direction | Value change up | Y position + 20 down | Y position − 20 left | X position − 20 right | X position + 20 Write program code for Move(). Save your program. Copy and paste the program code into part 3(c)(ii) in the evidence document.

[2]
d

Write program code to declare a new instance of BikeCharacter with the identifier Karla. The starting X position is 100, the starting Y position is 50 and the character’s name is Karla. Save your program. Copy and paste the program code into part 3(d) in the evidence document.

[1]
e(i)

Write program code to: • take as input which of the two characters the user would like to move • take as input the direction the user would like the character to move • call the appropriate method to move the character • output the character’s new X and Y position in an appropriate format, for example: "Karla's new position is X = 100 Y = 200" All inputs require appropriate prompts and must be validated. Save your program. Copy and paste the program code into part 3(e)(i) in the evidence document.

[5]
e(ii)

Test your program twice with the following inputs. Test 1: jack right Test 2: karla down Take a screenshot of the output. Save your program. Copy and paste the screenshot into part 3(e)(ii) in the evidence document.

[2]

Mark scheme

9618/41 · Oct/Nov 2023

Download PDF

1a(i) · 5 marks

  • 1 mark

    Function header (and end where appropriate) taking one string parameter

  • 1 mark

    Calculating length of parameter string

  • 1 mark

    Looping correct number of times

  • 1 mark

    Checking the first character against all vowels

  • 1 mark

    Accessing the remainder of the string

  • 0 marks

    Remainder of function correct with nothing extra i.e. totalling, must match structure of given algorithm

1a(ii) · 2 marks

  • 1 mark

    Calling the function with "house"

  • 1 mark

    Outputting the return value

1a(iii) · 1 mark

  • 1 mark

    Screenshot outputting 3

1b(i) · 6 marks

  • 1 mark

    Recursive call

  • 1 mark

    Function header (and end where appropriate) taking string parameter (returning integer where given)

  • 1 mark

    Base case checking (length is 0) and returning 0

  • 1 mark

    Extracting first character and checking if a vowel …

  • 1 mark

    … if it is a vowel, returning 1 + recursive call with 1 less character

  • 1 mark

    … if not a vowel, return recursive call with 1 less character

1b(ii) · 1 mark

  • 1 mark

    Calling recursive function with "imagine" and outputting return value

1b(iii) · 1 mark

  • 1 mark

    Screenshot showing 4

2a(i) · 2 marks

  • 1 mark

    (Global) array with identifier Queue with (minimum) 50 elements (of type string)

  • 1 mark

    TailPointer (integer) initialised to 0, HeadPointer (integer) initialised to -1

2a(ii) · 4 marks

  • 1 mark

    Procedure Enqueue() header (and close where appropriate) with one (string) parameter

  • 1 mark

    Checking if queue is full and outputting suitable message

  • 1 mark

    … otherwise inserting parameter to next space

  • 1 mark

    … increment TailPointer and set HeadPointer to 0 if first item (HeadPointer = -1)

2a(iii) · 4 marks

  • 1 mark

    Function header Dequeue() (and end where appropriate) with no parameter

  • 1 mark

    Checking if empty …

  • 1 mark

    … outputting suitable message and returning "Empty"

  • 1 mark

    (otherwise) incrementing head pointer

  • 0 marks

    returning next value (at head pointer before incrementing)

2b · 6 marks

  • 1 mark

    Procedure header ReadData() with no parameters

  • 1 mark

    Opening file …

  • 1 mark

    … and closing file

  • 1 mark

    Looping until EOF/set amount

  • 1 mark

    Reading in each value

  • 1 mark

    … calling Enqueue() with each value

  • 0 marks

    Use of exception handling with appropriate output

2c(i) · 2 marks

  • 1 mark

    Declaration of record type/class RecordData

  • 1 mark

    ID as a string and total as an Integer

2c(ii) · 2 marks

  • 1 mark

    (global) 1D Array named Records of type RecordData

  • 1 mark

    (global) NumberRecords declared as integer and initialised to 0

2c(iii) · 5 marks

  • 1 mark

    Incrementing NumberRecords each time (twice) a new record is added

  • 1 mark

    Procedure header (and end) and using Dequeue() and storing/using return value DataAccessed  Dequeue()

  • 1 mark

    Checking if NumberRecords is 0 and creating a new record with ID and total as 1: IF NumberRecords = 0 THEN Records[NumberRecords].ID  DataAccessed Records[NumberRecords].Total  1 Flag  TRUE

  • 1 mark

    Looping through all array elements to find matching ID and incrementing total if found FOR X  0 TO NumberRecords – 1 Check Python loop end IF Records[X].ID = DataAccessed THEN Records[X].Total  Records[X].Total + 1 Flag  TRUE ENDIF NEXT X

  • 1 mark

    Adding new record if record is not found, storing ID and total as 1 IF Flag = FALSE THEN Records[NumberRecords].ID  DataAccessed Records[NumberRecords].Total  1 NumberRecords  NumberRecords + 1 ENDIF

2d · 1 mark

  • 1 mark

    Looping through all array elements and outputting ID and total in correct format

2e(i) · 2 marks

  • 1 mark

    Calling ReadData() first and OutputRecords() last

  • 1 mark

    Looping through all queue elements and calling TotalData() for each queue element

2e(ii) · 1 mark

  • 1 mark

    Screenshot showing correct queue totals output

3a(i) · 4 marks

  • 1 mark

    Class header (and end where appropriate)

  • 1 mark

    Three attributes with correct names and data types

  • 1 mark

    Constructor header (and end where appropriate) with 3 parameters

  • 1 mark

    Within constructor, assigns attributes to parameters

3a(ii) · 3 marks

  • 1 mark

    1 get header with no parameter …

  • 1 mark

    … returning correct value

  • 1 mark

    2nd get method

3a(iii) · 4 marks

  • 1 mark

    1 set method header (and end where appropriate) with parameter …

  • 1 mark

    … adding parameter to X/Y Position attribute and storing in the X/Y attribute

  • 1 mark

    If (resulting value is) more than 10 000 limiting to 10 000 and if less than 0 limiting to 0

  • 1 mark

    Second correct set method

3a(iv) · 4 marks

  • 1 mark

    Method header with (string) parameter

  • 1 mark

    Checking parameter for direction …

  • 1 mark

    … using SetYPosition() and SetXPosition() correctly …

  • 1 mark

    … with correct parameters

3b · 2 marks

  • 1 mark

    New instance of Character created with identifier Jack …

  • 1 mark

    … correct constructor called and values passed

3c(i) · 3 marks

  • 1 mark

    Class header inheriting from Character

  • 1 mark

    Constructor taking all 3 parameters …

  • 1 mark

    … calling parent/super constructor with the 3 parameters

3c(ii) · 2 marks

  • 1 mark

    Method header taking parameter and overriding parent/super Move()

  • 1 mark

    Correct changes to method to update values by 20

3d · 1 mark

  • 1 mark

    Declaring new BikeCharacter with correct values e.g.

3e(i) · 5 marks

  • 1 mark

    Reading in both values (character and direction) with appropriate prompts

  • 1 mark

    Character name is validated as e.g. Jack/Karla, and direction is validated as e.g. up/down/left/right

  • 1 mark

    Calling Move() for the character input, with direction input as a parameter

  • 1 mark

    Outputting character's new X and Y position in a suitable format …

  • 1 mark

    … using get methods

3e(ii) · 2 marks

  • 1 mark

    Screenshot showing correct test for Jack moving right (X=60, Y=50)

  • 1 mark

    Screenshot showing correct test for Karla moving down (X=100, Y=30)

Questions

  1. 1
    Question 116 marks
    Mark scheme ›
  2. 2
    Question 229 marks
    Mark scheme ›
  3. 3
    Question 330 marks
    Mark scheme ›

More 9618 papers

Other papers from Oct/Nov 2023

Solve it on ExamPalStart