Past-paper question · 2025 October-November · Paper 22 · Q8

Question 8 2025 · October-November · Paper 22 · 15 marks

Original past-paper question for 8
Original past-paper question for 8
Original past-paper question for 8
Original past-paper question for 8
Reveal official mark-scheme answer Official mark-scheme answer for 8

Official answer for Question 8

✓
Use the tables for AO2 and AO3 below to award a mark in a suitable band using a best fit approach, then add up the total.

Question 15

✓
Marks are available for:
✓
•
✓
AO2 (maximum 9 marks)
✓
•
✓
AO3 (maximum 6 marks)
✓
Data Structures required with names as given in the scenario:
✓
Arrays or lists RandomNumber[], CountedNumber[]
✓
Requirements (techniques)
✓
R1 arrays and variables declared, then 100 000 random integers between 1 and 10, inclusive, generated and stored in an
✓
array, (array and variable declarations, iteration, random number generation, rounding and storage).
✓
R2 frequency of each random integer counted and results stored in array, then results sorted into descending order
✓
(initialisation, selection, counting, sort, nested iteration, storage).
✓
R3 calculation of the chance of each random integer occurring rounded to 4 d.p. and results output (iteration, rounding and
✓
output).
✓
Example 15-mark answer in pseudocode
✓
// array and variable declaration
✓
DECLARE RandomNumber : ARRAY[1:100000] OF INTEGER
✓
DECLARE CountedNumber : ARRAY[1:10, 1:2] OF INTEGER
✓
DECLARE Index1 : INTEGER
✓
DECLARE Index2 : INTEGER
✓
DECLARE Swap : BOOLEAN
✓
DECLARE Temp1 : INTEGER
✓
DECLARE Temp2 : INTEGER
✓
// generate 100000 random integers between 1 and 10, inclusive,
✓
// and store them in an array
✓
FOR Index1 1 TO 100000
✓
RandomNumber[Index1] ROUND(RANDOM() * 9, 0) + 1
✓
NEXT Index1
✓
0478/22
✓
Cambridge IGCSE – Mark Scheme
✓
October/November 2025
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 0478_w25_ms_22.pdf →

Show text version of question

Question 8

A
program is required to test the fairness of the random number generator.

The one‑dimensional (1D) array RandomNumber[] is used to store 100 000 random integers.

The two‑dimensional (2D) array CountedNumber[] is used to store the integers 1 to 10, inclusive, and the frequency of each integer (the number of times each integer was generated).

Write a program that meets the following requirements:

  • Generate 100 000 random integers between 1 and 10, inclusive.
  • Store each integer in the appropriate array.
  • Calculate the frequency of each of the integers 1 to 10 and store these values in the
  • appropriate array.

  • Sort the contents of the counted number array in descending order of frequency.
  • Calculate the chance of generating each of the integers 1 to 10, rounded to four decimal
  • places. Use the formula: chance = frequency / 100000

  • Output each of the integers 1 to 10 in the order they are stored in the counted number array,

along with the chance of generating them.

The following is an example of an algorithm that sorts a 2D array in an ascending order:

F TRUE WHILE F DO

F FALSE FOR I 1 TO 9 IF A[I, 2] > A[I + 1, 2] THEN T1 A[I, 1] T2 A[I, 2] A[I, 1] A[I + 1, 1] A[I, 2] A[I + 1, 2] A[I + 1, 1] T1 A[I + 1, 2] T2 F TRUE ENDIF NEXT I

ENDWHILE

You must use pseudocode or program code and add comments to explain how your code works.

All arrays, variables or constants used must be declared for this algorithm.

All inputs and outputs must contain suitable messages.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.......................................................................................................................................................... * 0000800000013 * DFD

Question 13

, ,

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

* 0000800000014 * DFD

Question 14

, ,

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..................................................................................................................................................

[15]

,

DFD

,

Question 15

* 0000800000016 * DFD

Question 16

, ,

Permission to reproduce items where third‑party owned material protected by copyright is included has been sought and cleared where possible. Every reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the publisher will be pleased to make amends at the earliest possible opportunity.

To avoid the issue of disclosure of answer‑related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cambridgeinternational.org after the live examination series.

Cambridge Assessment International Education is part of Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.

Topic relevance

Why this question appears here

98% assigned-topic match · Programming › Arrays

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 0478_w25_qp_22.pdf

Keep practising this topic