BREAKING
Student's code works, nobody knows why, including student★Local teen writes pseudocode, accidentally invents a language★Binary joke told in class, exactly 10 students laugh★
  1. Home
  2. A Level
  3. Computer Science
  4. OCR
  5. Recursion

OCR A Level Computer Science

Topic questions Programming fundamentals Recursion

Recursion

7 questions · 101 marks · about 2 hours

Recursion questions

OCR H446 Recursion 7 questions

Algorithms and programming June 2025, Question 1 22 marks

Data in a computer program needs to be sorted.

(a)
(a)(i)

Describe the steps a bubble sort will take to sort items into ascending order.

[5]
Reveal mark scheme Mark scheme for question 1(a)(i)
(a)(ii)

Darcie and Felix have both written a program that will perform a bubble sort to put these numbers into ascending order.

Figure for question 1

Darcie’s version will complete six passes. However, Felix’s version will only need to complete two passes.

Explain how Felix may have made his version more efficient than Darcie’s version.

[2]
Reveal mark scheme Mark scheme for question 1(a)(ii)
(b)

A second type of sorting algorithm is an insertion sort.

Describe how an insertion sort can be used to put the following data into ascending order.

Figure for question 1
[5]
Reveal mark scheme Mark scheme for question 1(b)
(c)

A third type of sorting algorithm is a quick sort.

The following quick sort algorithm is made up of two functions called partition() and quickSort(). The algorithm will sort an integer array into ascending numerical order.

Figure for question 1
(c)(i)

Identify which of the two functions is recursive and give all of the line numbers where recursive calls are made.

Recursive function name........

Recursive call line numbers........

[2]
Reveal mark scheme Mark scheme for question 1(c)(i)
(c)(ii)

Identify the type of iteration used in the function partition().

[1]
Reveal mark scheme Mark scheme for question 1(c)(ii)
(c)(iii)

Describe the role of the function partition() in the quick sort algorithm.

[3]
Reveal mark scheme Mark scheme for question 1(c)(iii)
(c)(iv)

The algorithm needs to be changed to sort the integer array into descending numerical order.

Identify the line number that needs to be changed and write the amended line of code.

Amended line of code........

[2]
Reveal mark scheme Mark scheme for question 1(c)(iv)
(c)(v)

The quick sort is an example of a divide-and-conquer algorithm.

Describe what divide-and-conquer means.

[2]
Reveal mark scheme Mark scheme for question 1(c)(v)

Algorithms and programming June 2023, Question 5 8 marks

A recursive pseudocode function, recursiveAlgorithm(), is shown.

Figure for question 5
(a)

Describe the key features of a recursive algorithm.

You may refer to the function, recursiveAlgorithm() in your answer.

[3]
Reveal mark scheme Mark scheme for question 5(a)
(b)

Trace the recursive function, recursiveAlgorithm(), and give the final return value when called with recursiveAlgorithm(10). You may choose to use the table below to give your answer.

Figure for question 5

Final return value........

[5]
Reveal mark scheme Mark scheme for question 5(b)

Algorithms and programming June 2022, Question 7 9 marks

Also involves Trace tables

A program uses the recursive function calculate(). The function is written in pseudocode.

Figure for question 7
(a)(i)

Give the line number in the algorithm calculate() where a recursive call is made.

[1]
Reveal mark scheme Mark scheme for question 7(a)(i)
(a)(ii)

State two features of any recursive algorithm.

[2]
Reveal mark scheme Mark scheme for question 7(a)(ii)
(b)

Trace the recursive function calculate() and give the final return value, when the following function call is run:

calculate(5)

You may choose to use the table below to give your answer.

Figure for question 7
[5]
Reveal mark scheme Mark scheme for question 7(b)
(c)

Give the pseudocode function call that would return 55 from the recursive function calculate().

[1]
Reveal mark scheme Mark scheme for question 7(c)

Algorithms and programming November 2020, Question 3 16 marks

Also involves Trace tables

Hugh has written a recursive function called thisFunction() using pseudocode.

Figure for question 3

The function DIV calculates integer division, e.g. 5 DIV 3 = 1

(a)
Figure for question 3 Figure for question 3
[5]
Reveal mark scheme Mark scheme for question 3(a)
(b)

State the name of the standard algorithm thisFunction() performs.

[1]
Reveal mark scheme Mark scheme for question 3(b)
(c)

Hugh could have written thisFunction() using iteration instead of recursion.

Compare two differences between recursion and iteration.

[4]
Reveal mark scheme Mark scheme for question 3(c)
(d)

The recursive function thisFunction() is printed again here for your reference.

Figure for question 3

Rewrite the function thisFunction() so that it uses iteration instead of recursion.

You should write your answer using pseudocode or program code.

[6]
Reveal mark scheme Mark scheme for question 3(d)

Algorithms and programming June 2019, Question 3 17 marks

Also involves Arithmetic operators

A recursive function, GCD, is given in pseudocode.

Figure for question 3
(a)

The function uses branching.

(a)(i)

Identify the type of branching statement used in the function.

[1]
Reveal mark scheme Mark scheme for question 3(a)(i)
(a)(ii)

Explain the difference between branching and iteration.

[2]
Reveal mark scheme Mark scheme for question 3(a)(ii)
(a)(iii)

Identify the two parameters in the function.

1

2.

[1]
Reveal mark scheme Mark scheme for question 3(a)(iii)
(a)(iv)

State whether the parameters should be passed by value, or by reference. Justify your answer.

[2]
Reveal mark scheme Mark scheme for question 3(a)(iv)
(a)(v)

Describe the arithmetic operation of MOD. Use an example in your answer.

[2]
Reveal mark scheme Mark scheme for question 3(a)(v)
(b)

Trace the recursive function when it is called by the statement GCD(250, 20). Give the final value returned.

Final return value:.

[3]
Reveal mark scheme Mark scheme for question 3(b)
(c)

The function has been rewritten using iteration instead of recursion.

(c)(i)

State one benefit and one drawback of using iteration instead of recursion.

Benefit.

Drawback.

[2]
Reveal mark scheme Mark scheme for question 3(c)(i)
(c)(ii)

Complete the missing statements in this iterative version of the function.

Figure for question 3
[4]
Reveal mark scheme Mark scheme for question 3(c)(ii)

Algorithms and programming June 2018, Question 4 19 marks

A recursive function, generate, is shown.

Figure for question 4
(a)

Trace the algorithm to show the value returned when generate(7) is called. Show each step of your working.

Figure for question 4

maths symbol

[6]
Reveal mark scheme Mark scheme for question 4(a)
(b)

The parameter, num1, is passed by value.

Explain why the parameter was passed by value instead of by reference.

Figure for question 4
[2]
Reveal mark scheme Mark scheme for question 4(b)
(c)

* Parameters can be used to reduce the use of global variables.

Compare the use of parameters to global variables in recursive functions.

Figure for question 4

maths symbol

[9]
Reveal mark scheme Mark scheme for question 4(c)
(d)

A student called Jason writes a recursive algorithm. The recursive algorithm uses more memory than if Jason had written it as an iterative algorithm.

Explain why the recursive algorithm uses more memory than the iterative algorithm.

Figure for question 4

maths symbol

[2]
Reveal mark scheme Mark scheme for question 4(d)

Algorithms and programming June 2017, Question 5 10 marks

A recursive function, calculate, is shown below:

Figure for question 5
(a)

Identify the lines where recursion is used.

[1]
Reveal mark scheme Mark scheme for question 5(a)
(b)

Trace the algorithm, showing the steps and result when the following line is run:

print(calculate(4,10))

[5]
Reveal mark scheme Mark scheme for question 5(b)
(c)

Re-write the function so it uses iteration instead of recursion.

[4]
Reveal mark scheme Mark scheme for question 5(c)

Report a problem with a question on this page
What is wrong?

Goes to whoever maintains the question split. No account needed and nothing is published on this page.

Memes

Certified Computer Science memes. Peer-reviewed by nobody.

Laugh now. Cry in the exam hall later. Then come back and do a past paper.

Write a proper algorithm
Write ‘sort it’ and leave
Me on the 6-mark pseudocode question
Debugging with print statements
Using a trace table
Knowing the difference between = and ==
Explaining recursion by explaining recursion
Code enlightenment, ranked

Mum 💖

can you fix the wifi since you do computers 🥰

that's not what computer science is

so that's a no then

📱 Screen time this week · Discord8h 2m

Turned it off and on again

Computer Science starter pack

Laptop with 47 tabs openPython error on line 1Counting binary on fingersThis website
Compiled with zero errors