2210/22/M/J/25 question 6: worked solution (May/June 2025, paper 22)
Show as plain textHide plain text
Cambridge O Level Computer Science 2210 · 7.7 Trace tables Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 6 of 8. Q63 2210/22/M/J/25 original Q6 Structured · 10 marks Worked solution (a) Run the algorithm line by line. V1 and V2 move towards each other. RACECAR reads the same both ways, so the loop ends when V1 and V2 meet. TREAT fails at the second check (R and A). Number Index Word Continue V1 V2 L1 L2 OUTPUT 2 1 RACECAR TRUE 1 7 R R 2 6 A A 3 5 C C 4 4 Successful 2 TREAT TRUE 1 5 T T 2 4 R A FALSE NOT successful Number and Index columns correct [1] Word column correct [1] Continue column correct [1] V1 and V2 columns correct [1] L1 and L2 columns correct [1] OUTPUT column correct [1] (b) State what the algorithm finds: It checks whether a word reads the same forwards and backwards (a palindrome ) [1] (c) Explain the two pointers V1 and V2. Any three of these: V1 marks the start and V2 marks the end of the part of the word being checked [1] After each check V1 is increased by 1 and V2 is decreased by 1 , moving towards the middle [1] When V1 = V2 or V1 > V2 (they meet or cross) all the letters have been checked, so the WHILE loop stops [1] The algorithm also stops early if two compared letters are different (Continue becomes FALSE). This also scores, but the part is marked out of 3. KEY IDEA Two pointers moving inwards from each end check a word, and the loop stops when they meet or a pair does not match. TOTAL 10 marks Official mark scheme VIDEO ▶ Topic lesson A lesson on this topic · by Mr Bulmer's Learning Zone. Tap the picture to open it on YouTube.