Skip to main content
A-LevelComputer ScienceProgramming9618/22 · May/June 2024 · Q610 Marks

A music player stores music in a digital form and has a display which shows the track being played. (a) Up to 16 characters can be displayed. Track titles longer than 16 characters will need to be trimmed as follows: • Words must be removed from the end of the track title until the resulting title is less than 14 characters. • When a word is removed, the space in front of that word is also removed. • Three dots are added to the end of the last word displayed when one or more words have been removed. The table below shows some examples: | Original title | Display string | |------------------------|--------------------------------------------| | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | | Bat out of Hull | B a t o u t o f H u l l | | Bohemian Symphony | B o h e m i a n . . . | | Paperbook Writer | P a p e r b o o k W r i t e r | | Chris Sings the Blues | C h r i s S i n g s . . . | | Green Home Alabama | G r e e n H o m e . . . | A function Trim() will: • take a string representing the original title • return the string to be displayed. Assume: • Words in the original title are separated by a single space character. • There are no spaces before the first word or after the last word of the original title. • The first word of the original title is less than 14 characters.

  1. (a)Write pseudocode for the function Trim().[7]
  2. (b)(i)Music is stored as a sequence of digital samples. Each digital sample is a denary value in the range 0 to 99999999 (8 digits). The samples are to be stored in a text file. Each sample is converted to a numeric string and 32 samples are concatenated (joined) to form a single line of the text file. Each numeric string is 8 characters in length; leading '0' characters are added as required. Example: | Sample | Denary value | String | |--------|--------------|------------| | 1 | 456 | "00000456" | | 2 | 48 | "00000048" | | 3 | 37652 | "00037652" | | ... | | | | 32 | 673 | "00000673" | The example samples will be stored in the text file as a single line: "000004560000004800037652...00000673" Identify one drawback of adding leading '0' characters to each numeric string.[1]
  3. (b)(ii)Suggest an alternative method of storing the samples which does not involve adding leading '0' characters but which would still allow each individual sample to be extracted.[1]
  4. (b)(iii)State one drawback of the alternative method given in part (b)(ii).[1]

Mark scheme

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

  1. [7] Mark as follows:
  2. 1. Function heading, ending, parameter and return type
  3. 2. If length of original string <= 16 then return original string
  4. 3. Any Conditional loop...
  5. 4. until string is short enough
  6. 5. Inner conditional loop / second condition to identify word(s) to remove from the end of string // Check to identify word(s) to remove from the end of string
  7. 6. Attempt to strip characters back to space
  8. 7. Correct removal of word/words from end of string and remove final space
  9. 8. Concatenate Dots and return result
  10. [1] A (very) large file is created // redundant zeroes are stored in the file
  11. [1] One mark for: Values are delimited by a special character / a separator character // First character indicates sample length
  12. [1] The algorithm to store / extract / separate the individual values is more complex / takes longer to execute / run / process

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, 10 marks.
Source
A-Level Computer Science, May/June 2024 Paper 2 Variant 2, question 6.

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