Skip to main content
A-LevelComputer ScienceProgramming9618/41 · May/June 2024 · Q127 Marks

A program needs to take integer numbers as input, sort the numbers and then search for a specific number.

  1. (a)The integer numbers will be stored in the global 1D array, DataStored, with space for up to 20 integers. The global variable NumberItems stores the quantity of items the array contains. Write program code to declare DataStored and NumberItems.[1]
  2. (b)The procedure Initialise(): • prompts the user to input the quantity of numbers the user would like to enter • reads the input and validates it is between 1 and 20 (inclusive) • prompts the user to input each number and stores each number in DataStored. Write program code for Initialise().[5]
  3. (c)(i)Write program code for the main program.[2]
  4. (c)(ii)Test your program by inputting the following data in the order given: 30 5 3 9 4 1 2 Take a screenshot of the output(s).[2]
  5. (d)(i)Write program code for BubbleSort().[4]
  6. (d)(ii)Write program code to amend the main program to call BubbleSort() and then output the contents of DataStored.[1]
  7. (d)(iii)Test your program by inputting the following data in the order given: 5 3 9 4 1 2 Take a screenshot of the output(s).[1]
  8. (e)(i)Write program code for the iterative function BinarySearch().[6]
  9. (e)(ii)Write program code to amend the main program to: • take a number as input from the user • call BinarySearch() with the number input • output the value returned from the function call as its parameter.[3]
  10. (e)(iii)Test your program twice with the following inputs: Test 1: 5 1 6 2 8 10 2 Test 2: 5 1 6 2 8 10 7 Take a screenshot of the output(s).[2]

Mark scheme

Marking points from the official mark scheme (May/June 2024). The mark or mark type is shown in brackets.

  1. [1] 1 mark for: • Declaration of (global) array with identifier DataStored (Integer and 20 spaces) and NumberItems (Integer)
  2. [5] 1 mark each • Procedure heading (and close where appropriate) with no parameter. • Prompt/output of suitable message to request the input of the quantity of numbers and reading in quantity of numbers and storing/using ... • each input in next space in DataStored
  3. [2] 1 mark each: • Storing 0 in NumberItems and then calling Initialise() • Outputting all contents of array DataStored
  4. [2] 1 mark each • Output showing quantity entered twice (30 and 5) with first being invalid • Array output 3 9 4 1 2
  5. [4] 1 mark each • Procedure header (and end where appropriate) and looping through each array element • Working inner loop • ...comparison of elements... • ...swapping of elements
  6. [1] 1 mark for calling BubbleSort() and outputting array contents after
  7. [1] 1 mark for screenshot showing the inputs and the values in the correct order
  8. [6] 1 mark each • Function header BinarySearch taking DataToFind as a parameter • Calculating the mid value (First + Last) \ 2 or equivalent inside loop • Checking if the data at mid is the parameter and returning mid inside loop • If DataToFind < mid, updating Last/Upper with mid – 1 inside loop • If DataToFind > mid, updating First/Lower with mid + 1 inside loop • Returning -1 when not found and a suitable loop with end criteria
  9. [3] 1 mark each: • Taking number as input • ... calling BinarySearch with input • Outputting value returned
  10. [2] 1 mark for each test

Write your answer and get it marked

On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.

Sign up free →

About this question

Topic
Programming, A-Level Computer Science (syllabus 9618). Structured question, 27 marks.
Source
A-Level Computer Science, May/June 2024 Paper 4 Variant 1, question 1.

Questions and mark schemes are from past examination papers and remain the copyright of the exam board. How Oracle Prep builds its content

Related Computer Science questions

© 2026 Oracle Prep