Skip to main content
O-LevelComputer ScienceAlgorithm design and problem-solving2210/22 · May/June 2025 · Q610 Marks

This pseudocode is an algorithm. DECLARE Word : STRING DECLARE V1 : INTEGER DECLARE V2 : INTEGER DECLARE Number : INTEGER DECLARE Index : INTEGER DECLARE L1 : CHAR DECLARE L2 : CHAR DECLARE Continue : BOOLEAN INPUT Number FOR Index ← 1 TO Number INPUT Word Continue ← TRUE V1 ← 1 V2 ← LENGTH(Word) WHILE Continue = TRUE AND V1 < V2 DO L1 ← SUBSTRING(Word, V1, 1) L2 ← SUBSTRING(Word, V2, 1) IF L1 <> L2 THEN Continue ← FALSE ELSE V1 ← V1 + 1 V2 ← V2 - 1 ENDIF ENDWHILE IF Continue = TRUE THEN OUTPUT "Successful" ELSE OUTPUT "NOT successful" ENDIF NEXT Index

  1. (a)Complete the trace table for the algorithm, using the input data: 2, RACECAR, TREAT Number Index Word Continue V1 V2 L1 L2 OUTPUT[6]
  2. (b)State the purpose of the algorithm on page 6.[1]
  3. (c)Explain how the algorithm knows when all the letters in the word have been checked so that it can stop checking.[3]

Mark scheme

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

  1. [6] (a) One mark per mark point MP1 Correct Number and Index columns MP2 Correct Word column MP3 Correct Continue column MP4 Correct v1 and v2 column MP5 Correct L1 and L2 column MP6 Correct OUTPUT column
  2. (a) Trace Table (expected content, row by row where changes occur):
  3. Number: 2
  4. Index: 1
  5. Word: RACECAR
  6. Continue: TRUE
  7. V1: 1
  8. V2: 7
  9. L1: R
  10. L2: R
  11. V1: 2
  12. V2: 6
  13. L1: A
  14. L2: A
  15. V1: 3
  16. V2: 5
  17. L1: C
  18. L2: C
  19. V1: 4
  20. V2: 4
  21. OUTPUT: Successful
  22. Index: 2
  23. Word: TREAT
  24. Continue: TRUE
  25. V1: 1
  26. V2: 5
  27. L1: T
  28. L2: T
  29. V1: 2
  30. V2: 4
  31. L1: R
  32. L2: A
  33. Continue: FALSE
  34. OUTPUT: NOT successful
  35. [1] (b) Finds words that read the same forwards and backwards.
  36. [3] (c) One mark per mark point, max three MP1 Uses an index to mark the start and end of each word // uses V1 to mark the start of the word and V2 to mark the end MP2 After each check, these are moved to the next character in the word at each end of the word // V1 is incremented by 1 and v2 is decremented by 1 after each check. MP3 When the two indexes match or cross, the whole word has been checked // When V1 = V2 or V1 > V2, the whole word has been checked MP4 The algorithm will exit if it is found that two compared letters are not the same.

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
Algorithm design and problem-solving, O-Level Computer Science (syllabus 2210). Structured question, 10 marks.
Source
O-Level Computer Science, May/June 2025 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