Cambridge AS & A Level Computer Science 9618/42 May/June 2026 (Paper 4 Practical): Task-by-Task Guide
Past Papers

Cambridge AS & A Level Computer Science 9618/42 May/June 2026 (Paper 4 Practical): Task-by-Task Guide

Mahira Kitchil Project Head, Tutopiya
• 10 min read
Updated

Cambridge AS & A Level Computer Science 9618/42 is the May/June 2026 Paper 4 (Practical), variant 2. It is an A Level component that lasts 2 hours 30 minutes and is worth 75 marks. It had three compulsory programming tasks, written on a computer in Java, Python or Visual Basic, with every answer pasted into an evidence document. Question 2, an Avatar class loaded from a text file, was the biggest at 30 marks. This guide goes through the paper task by task and shows what the official mark scheme gave marks for. The paper and its mark scheme are free on the Tutopiya Learning Portal.

For an overview of all four 9618 papers from this series, see A Level Computer Science 9618 May/June 2026 past papers: what came up and how it was marked.

9618/42 at a glance

QuestionTaskCode marksTest marksTotal
1Array of nine strings: longest and shortest, insertion sort16218
2Avatar class: constructor, get methods, MeetCriteria(), loading from AvatarFile.txt, validated choices28230
3Linked list in a 2D array: initialising, printing both lists, AddItem()24327
Total68775

The test marks are for screenshots of your program running. Nothing outside the evidence document is marked.

Task-by-task walkthrough

Question 1: sorting an array of strings (18 marks)

  • 1(a) Declare TheData (2 marks): one mark for an array with space for nine strings, one for storing laptop, tablet, printer, computer, processor, monitor, memory, cable and touchscreen in that order.
  • 1(b)(i) FindLongestShortest() (5 marks): a procedure that takes a string array, works out the longest and shortest strings without built-in max or min functions (a length function is allowed), and outputs both with messages. One mark each for the header with one array parameter, looping through every string, finding the shortest, finding the longest, and the two output messages. The logic: start the longest length at −1 and the shortest at a very large number; for each string, if its length beats the current longest, store it, and if it is shorter than the current shortest, store it; then output both.
  • 1(b)(ii) and (iii) (2 marks): call the procedure with TheData (1 mark), then a screenshot (1 mark). The output should say the longest word is touchscreen and the shortest is cable.
  • 1(c)(i) InsertionSort() (5 marks): a function that takes a string array, sorts it into ascending alphabetical order with an insertion sort (no built-in sort) and returns it. It has to work for an array of any length. One mark each for the header with the array parameter; looping through each element; using the insertion method (take an element out and move larger ones up a place); comparing strings correctly in your language (in Java, compareTo rather than <); and returning the sorted array. In outline:
for i from the second element to the last:
    Temp ← array[i];  j ← i − 1
    while j >= 0 and Temp < array[j]:
        array[j + 1] ← array[j];  j ← j − 1
    array[j + 1] ← Temp
return array
  • 1(c)(ii) Main program (3 marks): output “Before sorting” and the array; call InsertionSort() and store or use the array it returns; output “After sorting” and the sorted array.
  • 1(c)(iii) Screenshot (1 mark): the unsorted array, then cable, computer, laptop, memory, monitor, printer, processor, tablet, touchscreen. This mark followed through from your own array and messages.

Question 2: the Avatar class (30 marks)

Each avatar has a name, whether it wears glasses (Boolean), a hair colour and an age.

  • 2(a)(i) Class and constructor (4 marks): four private attributes with the right data types; the class header; a constructor taking four parameters (five in Python, counting self); and assigning the parameters to the attributes. In Python, the attribute types go in comments.
  • 2(a)(ii) GetName() and GetAge() (3 marks): a get method header with no parameter, returning the right attribute, then the second get method.
  • 2(a)(iii) MeetCriteria() (2 marks): takes a Boolean glasses choice and a string hair colour and returns TRUE only if both match this avatar’s attributes, FALSE otherwise. One mark for the header with both parameters and a Boolean returned in every case, one for comparing with the right attributes. Use .equals() for the string comparison in Java.
  • 2(b)(i) LoadAvatars() (7 marks): read AvatarFile.txt, where each of the 30 lines holds a name, True or False, a hair colour and an age separated by spaces, and store an Avatar object for each line in the global array AvailableAvatars. One mark each for: the header with exception handling and an error message; opening the file to read and closing it; looping to the end of the file (or 30 times); reading each line; splitting it at the spaces; creating the object with the right values; and storing it in the global array. The second value is text, so convert it to a Boolean (Python’s bool() returns True for any non-empty string, including “False”, so compare it with “True” instead), and convert the age to an integer.
  • 2(b)(ii) (1 mark): call LoadAvatars() from the main program.
  • 2(c)(i) EnterChoices() (6 marks): prompt for and input the two choices; validate them (glasses must be yes or no, and hair must be black, blonde, brown, pink, red or green, re-asking until valid); loop through every avatar; call MeetCriteria() for each and use its result; pass the right glasses and hair values; and store the matches in a global array. The scheme’s own example offered the six colours as a numbered menu, which does the same job as checking the typed word.
  • 2(c)(ii) Main program (5 marks): call EnterChoices(); count and output how many avatars matched; loop through the matches; output each name and age with a message; and do it through GetName() and GetAge(), since the attributes are private.
  • 2(d) Two test runs (2 marks): with glasses yes, an invalid colour (blue) and then black, the scheme’s example output shows 4 avatars: Dax (22), Pia (22), Rei (18) and Ren (19). With glasses no and hair green, the output is 0 avatars. Each screenshot had to show the inputs and output, and an appropriate message from your own program was accepted.

Question 3: a linked list in a 2D array (27 marks)

LinkedList holds up to eight integers. Each row is a data value and a pointer; −1 as data means an empty node and −1 as a pointer means the end of a list. StartLinkedList is 2 and StartEmptyList is 7.

  • 3(a) Declare and initialise (5 marks): a global 2D integer array of 8 × 2; StartLinkedList set to 2; StartEmptyList set to 7; the given data stored; and in the right indices.
  • 3(b)(i) PrintListItems() (4 marks): start at StartLinkedList, follow the pointers, output each node’s data, and stop at the null pointer. Make sure the last node (the one with pointer −1) is still printed.
  • 3(b)(ii) PrintEmptyList() (3 marks): the same idea from StartEmptyList, outputting each node’s index rather than its data: start in the right place, follow pointers and output, stop correctly.
  • 3(b)(iii) and (iv) (4 marks): output “Linked list” and call PrintListItems(), then “Empty list” and call PrintEmptyList() (2 marks). The screenshot (one mark per list) should show 1999, 9512, 5612, 5541, 6651 for the linked list and 7, 4, 6 for the empty list.
  • 3(c)(i) AddItem() (8 marks, max 8 from nine points): add a new value at the end of the list. In outline:
if StartEmptyList = −1: output "List is full"
else:
    NewNode ← StartEmptyList
    NextFree ← pointer of NewNode
    store the item in NewNode with pointer −1
    Current ← StartLinkedList
    while pointer of Current <> −1: Current ← pointer of Current
    pointer of Current ← NewNode
    StartEmptyList ← NextFree

Points: the header with an integer parameter; checking for a full list; outputting “List is full”; storing the item at StartEmptyList; with a pointer of −1; starting at StartLinkedList; following pointers to the last node; changing that node’s pointer to the new node; and moving StartEmptyList to the next free node. Save the next free node before you overwrite the new node’s pointer, or the empty list is lost.

  • 3(c)(ii) and (iii) (3 marks): call AddItem(8451), then both print procedures with headings (2 marks). The screenshot (1 mark) should show the linked list ending 6651, 8451 and the empty list 4, 6.

Where the marks are on 9618/42

SkillQuestionsMarks
Writing procedures, functions and methods1(b)(i), 1(c)(i), 2(a)(ii), 2(a)(iii), 2(b)(i), 2(c)(i), 3(b)(i), 3(b)(ii), 3(c)(i)43
Main program calls and outputs1(b)(ii), 1(c)(ii), 2(b)(ii), 2(c)(ii), 3(b)(iii), 3(c)(ii)14
Declaring and initialising data1(a), 3(a)7
Test screenshots1(b)(iii), 1(c)(iii), 2(d), 3(b)(iv), 3(c)(iii)7
Class declaration and constructor2(a)(i)4
Total75
  • The three biggest single parts are LoadAvatars() (7), AddItem() (8) and EnterChoices() (6). File reading with exception handling and pointer updates are worth practising until they’re automatic.
  • 28 marks are quick: the declarations, main program calls and screenshots. Do them as you go, even if a subroutine isn’t finished.

How to self-mark 9618/42 with the mark scheme

  1. Check your evidence document first. Any part with no code or screenshot pasted in scores nothing, however good the program.
  2. Tick mark points, not whole programs. Each subroutine is broken into separate points such as the header, the loop and the return. A program that crashes can still earn most of them.
  3. Watch the linked points. Where one point starts with ”…”, it needs the point before it: in EnterChoices(), passing the right values only counts if you looped and called MeetCriteria().
  4. Compare your outputs with the expected values above. The screenshot marks follow through from your own data and messages, but a wrong sorted order or wrong list order shows a logic error to fix.
  5. Run the tests exactly as the paper sets them, including the invalid colour in 2(d)(i), so your screenshot shows the validation working.
  6. Check the pointer updates in AddItem() by printing both lists before and after. The empty list must lose index 7 and keep 4 and 6.

Sit 9618/42 as a timed mock

The paper allows 150 minutes for 75 marks. Sit it on a computer with no internet, saving code and screenshots into a document as you go.

BlockMarksTime
Question 11834 minutes
Question 23060 minutes
Question 32750 minutes
Check evidence document–6 minutes
Total75150 minutes

If a subroutine won’t run, paste in what you have and move on. Partial code still earns its mark points.

Other May/June 2026 9618 papers

Practise and download

Need help with a 9618 topic? Book a free trial lesson with an A Level Computer Science tutor →

Frequently asked questions

What did 9618 Paper 42 May/June 2026 ask you to program? +

Three tasks: an array of nine strings with a procedure to find the longest and shortest string and an insertion sort function; an Avatar class loaded from AvatarFile.txt with exception handling, validated user choices and a list of matching avatars; and a linked list stored in a 2D array with an empty list, two print procedures and an AddItem() procedure.

How many marks is 9618/42 and how long is it? +

It is out of 75 marks and lasts 2 hours 30 minutes, programmed on a computer in Java, Python or Visual Basic (console mode). Question 2, the Avatar class, was the biggest at 30 marks.

What should the 9618/42 Question 1 outputs show? +

The longest string is touchscreen and the shortest is cable. After the insertion sort, the array reads cable, computer, laptop, memory, monitor, printer, processor, tablet, touchscreen.

What should the linked list print in 9618/42 Question 3? +

Following the pointers from index 2 gives 1999, 9512, 5612, 5541 and 6651, and the empty list is indexes 7, 4 and 6. After AddItem(8451), the linked list ends with 8451 and the empty list is 4 and 6.

How was AddItem() marked in 9618/42? +

Up to 8 marks from nine points: the header with an integer parameter; checking whether the list is full and outputting List is full; storing the data at StartEmptyList with a pointer of -1; starting at StartLinkedList and following pointers to the last node; changing that node's pointer to the new node; and updating StartEmptyList to the next free node.

Where can I download 9618/42 May/June 2026 and its mark scheme? +

Both are free to download and print on the Tutopiya Learning Portal, on the Cambridge AS & A Level Computer Science 9618 past papers page.

Ready to Excel in Your Studies?

Get personalised help from Tutopiya's expert tutors. Whether it's IGCSE, IB, A-Levels, or any other curriculum — we match you with the perfect tutor and your first session is free.

Book Your Free Trial
M

Written by

Mahira Kitchil

Connect on LinkedIn →

Project Head, Tutopiya

Mahira Kitchil is a Project Head at Tutopiya, where she works with Cambridge IGCSE and Edexcel A-Level teachers in more than 20 countries on how exams are set and marked. She writes practical guides that help students find the right past papers and use the mark scheme the way examiners do, so every practice paper counts.

Get Started

Courses

Company

Subjects & Curriculums

Resources

Book a Tutor

Struggling with this topic?

Practise A Level Computer Science with free topic quizzes