Signed up recently but had issues with the confirmation email?

Click Forgot password and follow the reset steps. You can choose the same password you used when you signed up. This should then provide access.

Remember to check Spam and Junk. The email will be from auth@progressbytes.co.uk.

Revision notesQuestionsFor schools
Revise Computing
Log inStart revising free
Revision notesQuestionsFor schoolsLog in

© 2026 Revise Computing · revisecomputing.co.uk

Worried about something?Question Bank UpdatesPrivacy noticeTermsContact

Revise Computing is an independent revision resource. It is not affiliated with, or endorsed by, OCR (Oxford Cambridge and RSA Examinations).

Knowledge/A Level/H446/02 Algorithms and programming/Programming Techniques/Recursion, how it can be used…

Recursion, how it can be used and how it compares to an iterative approach

Recursion, how it can be used and compares to an iterative approach.

2.2.1 Programming Techniques

Practise exam questions

Programming Techniques — Note 2 of 6

Candidates need to understand the principle of recursion and the key features of a recursive algorithm, such as a stopping condition. Candidates need to be able to read, trace and write recursive functions, and translate between recursive and iterative solutions. Candidates need to understand the benefits and drawbacks of recursive and iterative solutions.

What you need to know

A recursive subroutine calls itself, working on a smaller version of the problem each time until it reaches a base case. Many problems, such as tree traversal and divide and conquer algorithms, are naturally recursive.

What to know

  • A recursive subroutine must have a BASE CASE (a stopping condition that returns a value without a recursive call) and must move towards the base case with each call.
  • Each call is placed on the call stack with its own parameters, local variables and return address; when the base case is reached, the calls return one by one in reverse order (unwinding).
  • Benefits of recursion: can need fewer lines of code and be more natural for problems that are recursive in nature (e.g. tree traversal, merge sort, quick sort).
  • Drawbacks of recursion: uses more memory because of the stack frames; can be slower; if the base case is never reached, or the recursion is too deep, a stack overflow occurs; can be harder to trace.
  • Iteration uses a loop instead; it is usually more memory-efficient, but can be harder to write for naturally recursive problems.
  • Any recursive algorithm can be rewritten iteratively, and vice versa.

Code examples

Factorial: recursive and iterative versions
python
def factorial_recursive(n):
    if n <= 1:                  # base case
        return 1
    return n * factorial_recursive(n - 1)   # recursive call

def factorial_iterative(n):
    result = 1
    for i in range(2, n + 1):
        result = result * i
    return result

print(factorial_recursive(4))   # 24: 4 * 3 * 2 * 1
print(factorial_iterative(4))   # 24

Key terms

Recursion

A subroutine that calls itself.

Exam technique

  • Tip:You need to read, trace and write recursive functions, and convert between recursive and iterative versions.
  • Tip:A recursive subroutine needs a base case, where it stops without calling itself again (there may be more than one), and a general case where it calls ITSELF, not just 'calls a function'. For the PURPOSE of a base case, say it stops any further recursive calls and starts the unwinding. 'It ends the function' is not enough.
  • Tip:To trace recursion, write one line per call with its arguments. Keep going until the call that reaches the base case, then unwind, writing the value each call returns. If the first call sits inside print, the final value is also output. Copy that output exactly: if the function builds a string, keep every character, including any leading zeros.
  • Tip:An iterative version must not call itself. Loop until the base case's condition is true, changing variables as each call changed its arguments; if results combine on the way back (e.g. factorial), keep a running total. Return after the loop, or inside it to stop early.
  • Mistake:Forgetting the base case, or writing a recursive call that does not move towards it.

Past exam questions

  • June 2026Paper 2Q6(a)2marks
  • June 2026Paper 2Q6(b)5marks
  • June 2026Paper 2Q6(c)2marks
  • June 2026Paper 2Q6(d)2marks
  • June 2025Paper 2Q1(c)(i)2marks
  • June 2023Paper 2Q5(a)3marks
  • June 2023Paper 2Q5(b)5marks
  • June 2022Paper 2Q7(a)(i)1mark
  • June 2022Paper 2Q7(a)(ii)2marks
  • June 2022Paper 2Q7(b)5marks
  • June 2022Paper 2Q7(c)1mark
  • November 2020Paper 2Q3(a)5marks
  • November 2020Paper 2Q3(c)4marks
  • November 2020Paper 2Q3(d)6marks
  • June 2019Paper 2Q3(b)3marks
  • June 2019Paper 2Q3(c)(i)2marks
  • June 2019Paper 2Q3(c)(ii)4marks
  • June 2018Paper 2Q4(a)6marks
  • June 2018Paper 2Q4(d)2marks
  • June 2017Paper 2Q5(a)1mark
  • June 2017Paper 2Q5(b)5marks
  • June 2017Paper 2Q5(c)4marks

Ready to test yourself?

Practise 2.2.1 questions
← Previous noteProgramming constructs: sequence, iteration, branching2.2.1 Programming TechniquesNext note →Global and local variables2.2.1 Programming Techniques

Back to Programming Techniques

Programming Techniques

Note 2 of 6

  1. 1Programming constructs: sequence, iteration, branching
  2. 2Recursion, how it can be used and how it compares to an iterative approach
  3. 3Global and local variables
  4. 4Modularity, functions and procedures, parameter passing by value and by reference
  5. 5Use of an IDE to develop/debug a program
  6. 6Use of object oriented techniques
Topic overview