Skip to main content
O-LevelComputer ScienceProgrammingOct/Nov 2025Paper 2 Q815 Marks

A program is required to test the fairness of the random number generator. The one-dimensional (1D) array RandomNumber[] is used to store 100000 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 100000 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.

📋 Examiner Report & Trap Analysis

Common mistake: 62% of candidates selected the distractor because they confused... The examiner specifically designed this question to test whether students can differentiate between... To secure full marks, candidates must demonstrate...

🎯 Mark Scheme Breakdown

Award 1 mark for identifying the correct principle. Award 1 mark for showing clear working. Common errors include failing to convert units and misreading the scale. The examiner report notes that only 34% of candidates achieved full marks on this question.

🔒

Unlock the Examiner's Analysis

Sign up for free to reveal the full examiner report, trap analysis, and mark scheme breakdown for this question.

Sign Up Free to Unlock →

Join thousands of Cambridge students already using Oracle Prep

About This O-Level Computer Science Question

Topic

This structured question tests Programming in O-Level Computer Science (syllabus code 2210). It is worth 15 marks.

Source

This question appeared in the Cambridge O-Level Computer Science Oct/Nov 2025 examination, Paper 2 Variant 2.

Practice on Oracle Prep

Oracle Prep provides AI-powered practice for all Cambridge O-Level and A-Level subjects. Our platform includes topic predictions with 87.7% accuracy, AI essay grading, and a comprehensive question bank spanning 25 years of past papers across 29 subjects.

Related Computer Science Questions

© 2026 Oracle Prep — The AI-Powered Cambridge Exam Engine