Question 2(e) 2025 · May-June · Paper 42 · 16 marks
Reveal official mark-scheme answer

Official answer for Question 2
Part (e)
Question 1
mark each to max 5
Question 5
- Procedure header (and end where appropriate), opening and closing file HashData.txt
- Reading in all lines of data …
- … splitting each line by commas
- Creating record with correct values with each line read in from file
- Calling InsertIntoHash() with each record they have created
- Exception handling for opening and reading from file with appropriate catch and output.
Show text version of question
Question 2
Part (e)
Question 2
The total is initialised to the first value in the stack: 10
total = 10
The next two values are: + 3
total = 10 + 3 = 13
The next two values are: – 2
total = 13 – 2 = 11
The final total is 11 and this is returned.
Write program code for the function Calculate() to:
- take each value from the stack
- calculate and return the final total.
Save your program.
Copy and paste the program code into part 1(e) in the evidence document.
Question 5
Part (f)
(i)
Write program code to extend the main program to:
- take a filename as input from the user
- call ReadData() with the input filename
- call Calculate()
- output the final total.
Save your program.
Copy and paste the program code into part 1(f)(i) in the evidence document.
(ii)
Test your program twice with the file names:
StackData.txt SecondStack.txt
Take a screenshot of the output(s).
Save your program.
Copy and paste the screenshot into part 1(f)(ii) in the evidence document.
Question 6
2 A program stores data in a 1D array of records, HashTable. The array has space for 200 records. Each data item is stored in a specific index of the array that is calculated using an algorithm. The index is calculated from the key field using the formula: Key MOD 200
If two key fields generate the same index, there is a collision. Any records that have a collision are stored in a second array, Spare. This array has space for 100 records. When a collision is detected, the record is stored in the next free space in Spare.
Part (e)
The text file HashData.txt stores up to 200 rows of data to be stored into the hash table.
Each row contains three integer numbers separated by commas.
The first number is the key field, the second number is item 1 and the third number is item 2.
For example:
The first row in the text file contains: 646, 12, 568
The key field is 646, item 1 is 12 and item 2 is 568
The procedure CreateHashTable():
- opens the file HashData.txt
- creates a record for each row of data in the file
- calls InsertIntoHash() with each record.
Write program code for CreateHashTable()
Save your program.
Copy and paste the program code into part 2(e) in the evidence document.
Question 8
Why this question appears here
71% assigned-topic match · Data types and structures › Data types and records
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_s25_qp_42.pdf
