Skip to main content
A-LevelComputer ScienceProgramming9618/41 · Oct/Nov 2021 · Q117 Marks

Study the following pseudocode for a recursive function. FUNCTION Unknown(BYVAL X, BYVAL Y : INTEGER) RETURNS INTEGER IF X < Y THEN OUTPUT X + Y RETURN (Unknown (X + 1, Y) * 2) ELSE IF X = Y THEN RETURN 1 ELSE OUTPUT X + Y RETURN (Unknown (X 1, Y) DIV 2) ENDIF ENDIF ENDFUNCTION The operator DIV returns the integer value after division e.g. 13 DIV 2 would give 6

  1. (a)Write program code to declare the function Unknown(). Save your program as question 1. Copy and paste the program code into part 1(a) in the evidence document.[3]
  2. (b)(i)For each of the three function calls, the main program needs to: • output the value of the two parameters • call the function with those parameters • output the return value. Write the program code for the main program. Save your program. Copy and paste the program code into part 1(b)(i) in the evidence document.[3]
  3. (b)(ii)Take a screenshot to show the output from part (b)(i). Copy and paste the screenshot into part 1(b)(ii) in the evidence document.[2]
  4. (c)Rewrite the function Unknown() as an iterative function, IterativeUnknown(). Save your program. Copy and paste the program code into part 1(c) in the evidence document.[7]
  5. (d)(i)The iterative function needs to be called three times with the same parameters as in part (b). For each of the three function calls, the main program needs to: • output the value of the two parameters • call the iterative function with those parameters • output the return value. Amend the main program to perform these tasks. Save your program. Copy and paste the program code into part 1(d)(i) in the evidence document.[1]
  6. (d)(ii)Take one or more screenshots to show the output of both functions for each set of parameters. Copy and paste the screenshot(s) into part 1(d)(ii) in the evidence document.[1]

Mark scheme

Marking points from the official mark scheme (Oct/Nov 2021). The mark or mark type is shown in brackets.

  1. [1] function with correct name and parameters
  2. [1] correct Div operator (or equivalent) used
  3. [1] code matches pseudocode
  4. [1] Suitable output identifying parameters for each call
  5. [1] All three correct function calls
  6. [1] ...outputting the return value for each call
  7. [1] 1 mark for 1 function with correct output
  8. [1] 1 mark for remaining 2 function calls with correct output
  9. [1] Iterative function, taking 2 parameters
  10. [1] Starting with return value (Total) as 1
  11. [1] Looping while X <> Y // might be 1 loop or two separate // returning when X = Y // looping until X==Y
  12. [1] Within each loop, outputting (X+Y) correctly when X<Y and Y<X
  13. [1] Each time X < Y, Total * 2 and X++
  14. [1] Each time Y < X Total DIV 2 and X--
  15. [1] Returning the Total after correct calculations
  16. [1] Calling function 3 times with correct Data and outputting
  17. [1] 1 mark for screenshot showing correct output for both functions

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, 17 marks.
Source
A-Level Computer Science, Oct/Nov 2021 Paper 4 Variant 1, question 1.

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