Skip to main content
A-LevelComputer ScienceData types and structures9618/42 · May/June 2023 · Q114 Marks

A 1D array needs to store the names of 10 animals.

  1. (a)Write program code to declare the global string array Animals to store 10 items.[2]
  2. (b)The main program needs to store the following animals in the array: horse lion rabbit mouse bird deer whale elephant kangaroo tiger Write program code to store these animal names in the array. The names must be in lower case and stored in the order given in the list.[2]
  3. (c)The following pseudocode procedure sorts the array into a descending alphabetical order using only the first character in each animal name. The function LENGTH (DataArray) returns the number of elements in the array DataArray. The function MID(String, Start, Quantity) returns Quantity number of characters from String starting at index Start. The first character in the string is index 0, for example: MID("tiger", 0, 2) will return "ti" There are four incomplete statements in the procedure. PROCEDURE SortDescending() DECLARE ArrayLength : INTEGER DECLARE Temp : STRING ArrayLength ← LENGTH(Animals) FOR X ← 0 TO ArrayLength - 1 FOR Y ← .......... TO ArrayLength - X - 1 IF MID(Animals[Y], 0, 1) < MID(Animals […], 0, 1) THEN Temp ← Animals [..........] Animals [Y] ← Animals [Y + 1] Animals [Y + 1] ← .......... ENDIF NEXT Y NEXT X ENDPROCEDURE Write program code for the procedure SortDescending().[6]
  4. (d)(i)Write program code to amend the main program to: • call the procedure SortDescending() • output the sorted contents of the array with each animal name on a new line.[3]
  5. (d)(ii)Test your program. Take a screenshot of the output.[1]

Mark scheme

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

  1. [1] Global array named Animals
  2. [1] 10 string elements
  3. [1] Storing all 10 items in the array
  4. [1] in the correct order and all in lower case
  5. [1] Correct Y loop limit: TO ArrayLength - X - 1
  6. [1] Correct element in second MID: Animals [Y+1]
  7. [1] Correct element for Temp assignment: Temp ← Animals [Y]
  8. [1] Correct element for Animals[Y+1] assignment: Animals [Y + 1] ← Temp
  9. [1] Use of appropriate string functions to access e.g. MID and length
  10. [1] Remainder of procedure correct and following example
  11. [1] calling the procedure SortDescending()
  12. [1] looping through all array elements
  13. [1] outputting each array element on a new line
  14. [1] 1 mark for screenshot e.g. whale, tiger, rabbit, mouse, lion, kangaroo, horse, elephant, deer, bird

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
Data types and structures, A-Level Computer Science (syllabus 9618). Structured question, 14 marks.
Source
A-Level Computer Science, May/June 2023 Paper 4 Variant 2, 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