Mystery 2008

This is an algorithm trace task. No implementation is required.

Read the following algorithm for the recursive procedure called Mystery.


  • LEN(aSTRING) returns the number of characters in the string held in aString,
  • MID$(aString, n,m) returns m characters of aString starting at the nth,
  • LEFT$(aString, n) returns the first n characters of aString,
  • RIGHT$(aString, n) returns the last n characters of aString,
  • & joins two strings together (concatenation).

(a) Give the output if the procedure is called by MYSTERY(” ”, ”RED”) [7]

(b) The function is called with MYSTERY(” ”, ”AB”)

Write down all the instructions, including procedure calls, in the order in which they are executed. You must show the values of the variables in each instruction. [10]

This task was worth 17 Marks.  It was an algorithm trace task. No implementation is required that originally appeared in OCR 2507 Task 4 Jun 2008.  All rights and copyright to OCR.  Please refer to the OCR Copyright Statement for further information.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.