Skip to main content
A-LevelComputer ScienceProgramming9618/23 · May/June 2025 · Q58 Marks

A module Parity() takes a string as a parameter. The parameter has the identifier BitString and it represents a binary value. The module will concatenate a single character to the end of BitString by applying one of the two rules: : '0' if Bitstring contains an even number of 1s : '1' if Bitstring contains an odd number of 1s. The modified value of BitString is then returned. For example: Parameter String returned Explanation "0010010110" "00100101100" there are an even number of 1s in the string passed to Parity() so a '0' is concatenated to the end of BitString "101010" "1010101" there are an odd number of 1s in the string passed to Parity() so a '1' is concatenated to the end of BitString Write pseudocode for the module Parity() Assume the parameter BitString can only contain the characters '0' and '1'

  1. Write pseudocode for the module Parity() Assume the parameter BitString can only contain the characters '0' and '1'[8]

Mark scheme

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

  1. [8] Example solution: FUNCTION Parity(BitString : STRING) RETURNS STRING DECLARE Index, Count: INTEGER Count <- 0 FOR Index <- 1 TO LENGTH(BitString) IF MID(BitString, Index, 1) = '1' THEN Count <- Count + 1 ENDIF NEXT Index IF Count MOD 2 = 1 THEN BitString <- BitString & '1' ELSE BitString <- BitString & '0' ENDIF RETURN BitString ENDFUNCTION
  2. MP1 Function heading and ending and parameter (STRING) and return type STRING
  3. MP2 Loop for length of BitString
  4. MP3 Extract current character in a loop
  5. MP4 Compare current character to '1' or '0' in a loop
  6. MP5 Increment count and was Initialised earlier in a loop
  7. MP6 Check if even/odd number of 1s
  8. MP7 Append '1' or '0' as appropriate
  9. MP8 Return amended BitString

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, 8 marks.
Source
A-Level Computer Science, May/June 2025 Paper 2 Variant 3, question 5.

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