Past-paper question · 2025 October-November · Paper 43 · Q2(d)

Question 2(d) 2025 · October-November · Paper 43 · 5 marks

Original past-paper question for 2(D)
Original past-paper question for 2(D)
Reveal official mark-scheme answer Official mark-scheme answer for 2(D)

Official answer for Question 2

Part (d)

Question 1

mark each to max 5

Question 5

  • Procedure header (and end where appropriate)
  • Opening the file and closing the file (in appropriate place)
  • Looping until EOF // looping through each line …
  • … read in each value …
  • … calling Enqueue() with read in value and store/use return value
  • Exception handling with try except and appropriate output with all file access within try
✓
Example program code
✓
Java
✓
public static void ReadData(){
✓
Boolean ReturnValue;
✓
Boolean FinishLoop = false;
✓
try{
✓
Scanner Scanner1 = new Scanner(new File("BinaryData.txt"));
✓
while(Scanner1.hasNextLine() && FinishLoop == false){
✓
ReturnValue = Enqueue(Scanner1.nextLine());
✓
if(ReturnValue.equals("False")){
✓
FinishLoop = true;
✓
}
✓
}
✓
Scanner1.close();
✓
} catch(FileNotFoundException ex){
✓
System.out.println("No file found");
✓
}
✓
}
✓
9618/43
✓
Cambridge International AS & A Level – Mark Scheme
✓
October/November 2025
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9618_w25_ms_43.pdf →

Show text version of question

Question 2

Part (d)

Question 2

A
program reads string data from a text file into a linear queue and then compresses the data.

The queue is created using the global 1D array Queue. The queue can store up to 100 elements. Each element is initialised to the empty string "" The queue has two pointers that are global to the program: • QueueHead that points to the index of the first element in the queue, initialised to –1 • QueueTail that points to the index of the last element in the queue, initialised to –1 The global variable NumberItems stores the number of elements stored in the queue, initialised to 0

Part (d)

The text file BinaryData.txt stores individual binary digits, '1' and '0'. Each digit is on

a new line. For example, the first line in the text file stores '1', the second line stores '1' The procedure ReadData() reads in each line from the text file BinaryData.txt and inserts it into the queue using the appropriate method. The procedure needs to work for a text file with any number of lines up to a maximum of 100. Write program code for ReadData() Save your program. Copy and paste the program code into part 2(d) in the evidence document.

[5]
Topic relevance

Why this question appears here

72% assigned-topic match · Programming › Constructs

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 9618_w25_qp_43.pdf

Keep practising this topic