Mystery 2008

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

Read the following algorithm for the recursive procedure called Mystery.

mystery2008.jpg - 12/2015

Where

  • 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.

Comments 0

Write a Reply or Comment

We will not publish your email.*


*