Skip to main content
A-LevelComputer ScienceProgramming9618/21 · May/June 2022 · Q711 Marks

A string is a palindrome if it reads the same forwards as backwards. The following strings are examples of palindromes: "Racecar" "madam" "12344321" Upper-case and lower-case characters need to be treated the same. For example, 'A' is equivalent to 'a'.

  1. (a)A function IsPalindrome() will take a string parameter. The function will return TRUE if the string is a palindrome and will return FALSE if the string is not a palindrome. Write pseudocode for IsPalindrome().[7]
  2. (b)Strings may consist of several words separated by spaces. For example, the string "never odd or even" becomes a palindrome if the spaces are removed. The program flowchart represents an algorithm to produce a string OutString by removing all spaces from a string InString. [Figure 7.1] Complete the table by writing the text that should replace each of the labels B, C, D, F and G. Note: the text may be written as a pseudocode statement. Label | Text ---|--- A | Set OutString to "" B | C | D | E | Set Index to Index + 1 F | G |[4]

This question uses a diagram from the original paper, which isn't shown here. Open the full paper from the past papers archive to see it.

Mark scheme

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

  1. [7] (a) FUNCTION IsPalindrome(InString : STRING) RETURNS BOOLEAN
  2. [7] (a) DECLARE IsPal : BOOLEAN
  3. [7] (a) DECLARE Index, Num : INTEGER
  4. [7] (a) DECLARE CharA, CharB : CHAR
  5. [7] (a) IsPal ← TRUE
  6. [7] (a) Index ← 1
  7. [7] (a) Num ← INT(LENGTH(InString) / 2)
  8. [7] (a) WHILE Index <= Num AND IsPal = TRUE
  9. [7] (a) CharA ← MID(InString, Index, 1)
  10. [7] (a) CharB ← MID(InString, LENGTH(InString) - Index + 1, 1)
  11. [7] (a) IF UCASE(CharA) <> UCASE(CharB) THEN
  12. [7] (a) IsPal ← FALSE // RETURN FALSE
  13. [7] (a) ENDIF
  14. [7] (a) Index ← Index + 1
  15. [7] (a) ENDWHILE
  16. [7] (a) RETURN IsPal // RETURN TRUE
  17. [7] (a) ENDFUNCTION
  18. [7] (a) Mark as follows: 1 Functions header including parameter, ending and return type
  19. [7] (a) Mark as follows: 2 Calculation of number of pairs to match (length or half length)
  20. [7] (a) Mark as follows: 3 Loop for half or whole string
  21. [7] (a) Mark as follows: 4 ...Extracting characters to compare // create reverse string
  22. [7] (a) Mark as follows: 5 Convert characters to same case
  23. [7] (a) Mark as follows: 6 Check for_mismatch of characters inside loop / test for mismatch after loop for reversed string
  24. [7] (a) Mark as follows: 7 Returning Boolean in both cases
  25. [4] (b) Mark for each of: B
  26. [4] (b) Mark for each of: D
  27. [4] (b) Mark for each of: C
  28. [4] (b) Mark for each of: ...F and G
  29. [4] (b) Note: The mark for F and G is dependent on a reasonable attempt at C
  30. [4] (b) Label: B, Text: Is Index > LENGTH(InString)?
  31. [4] (b) Label: C, Text: Is MID (InString, Index, 1) = " "?
  32. [4] (b) Label: D, Text: Set OutString to OutString & MID(InString, Index, 1)
  33. [4] (b) Label: F, Text: YES
  34. [4] (b) Label: G, Text: NO

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, 11 marks.
Source
A-Level Computer Science, May/June 2022 Paper 2 Variant 1, question 7.

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