Skip to main content
EnglandComputer ScienceSyllabus dot point

What makes an algorithm recursive, and how does Big-O notation measure how efficiently an algorithm scales?

Recursion and algorithmic complexity: the base case and recursive case, how recursion uses the call stack, and Big-O notation for the time and space complexity of algorithms (constant, logarithmic, linear, polynomial and exponential).

An Eduqas Component 1 answer on recursion and complexity: the base case and recursive case, how recursion uses the call stack and can cause stack overflow, and Big-O notation for measuring how an algorithm's time and space scale with input size.

Generated by Claude Opus 4.814 min answer

Reviewed by: AI editorial process; not yet individually human-reviewed

Have a quick question? Jump to the Q&A page

Jump to a section
  1. What this dot point is asking
  2. The answer
  3. Examples in context
  4. Try this

What this dot point is asking

Eduqas wants you to explain recursion (the base case and recursive case and how the call stack supports it), and use Big-O notation to describe how an algorithm's time and space scale with input size. Expect to write or trace a recursive function and to compare or order complexities.

The answer

Recursion: base case and recursive case

The call stack and stack overflow

Big-O notation and complexity classes

Examples in context

Recursion expresses tree and graph traversals, the divide-and-conquer in merge sort and quick sort, and problems like the Towers of Hanoi cleanly, though each carries the call-stack cost. Big-O is the vocabulary engineers use to choose algorithms: a feature that works on 1,0001{,}000 items with an O(n2)O(n^2) method may freeze on a million, where an O(nlogn)O(n \log n) method still responds. This is why the searching and sorting dot points always pair an algorithm with its complexity, and why functional programming (later) leans on recursion in place of loops.

Try this

Q1. State the two parts every correct recursive subroutine must have. [2 marks]

  • Cue. A base case (stops the recursion) and a recursive case (calls itself on input closer to the base case).

Q2. Why can deep recursion cause a stack overflow? [1 mark]

  • Cue. Each call pushes a frame onto the call stack; if the recursion is too deep (or has no reachable base case), the stack runs out of space.

Q3. Place in order of efficiency for large nn, best first: O(n)O(n), O(1)O(1), O(n2)O(n^2), O(logn)O(\log n). [1 mark]

  • Cue. O(1)O(1), O(logn)O(\log n), O(n)O(n), O(n2)O(n^2).

Exam-style practice questions

Practice questions written in the style of WJEC Eduqas exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.

Eduqas 20205 marksWrite a recursive function to calculate n!n! (n factorial), clearly identifying the base case and the recursive case, and explain how the call stack is used when the function runs.
Show worked answer →

Recursive factorial (up to 3 marks):

FUNCTION factorial(n)
    IF n <= 1 THEN
        RETURN 1            // base case
    ELSE
        RETURN n * factorial(n - 1)   // recursive case
    ENDIF
ENDFUNCTION

The base case (n1n \leq 1 returns 11) stops the recursion; the recursive case multiplies nn by the factorial of n1n - 1.

Call stack (up to 2 marks): each call to factorial pushes a stack frame holding its n and return address before calling itself; the calls stack up until the base case returns, then the frames are popped in reverse, multiplying the results back up.

Markers reward the correct base and recursive cases and the description of frames being pushed on the way down and popped (with multiplication) on the way back up.

Eduqas 20224 marksExplain what Big-O notation describes, and place these complexities in order from most to least efficient for large nn: O(n2)O(n^2), O(1)O(1), O(nlogn)O(n \log n), O(logn)O(\log n).
Show worked answer →

Big-O describes how the running time (or memory) of an algorithm grows as the input size nn grows, focusing on the dominant term and ignoring constants, so it measures scalability rather than exact time (up to 2 marks).

Order from most to least efficient (up to 2 marks): O(1)O(1), then O(logn)O(\log n), then O(nlogn)O(n \log n), then O(n2)O(n^2).

Markers reward the growth-rate definition (worst-case scaling, dropping constants) and the correct ordering, with O(1)O(1) best and O(n2)O(n^2) worst of those listed.

Related dot points

Sources & how we know this