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.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
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 items with an method may freeze on a million, where an 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 , best first: , , , . [1 mark]
- Cue. , , , .
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 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 ( returns ) stops the recursion; the recursive case multiplies by the factorial of .
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 : , , , .Show worked answer →
Big-O describes how the running time (or memory) of an algorithm grows as the input size 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): , then , then , then .
Markers reward the growth-rate definition (worst-case scaling, dropping constants) and the correct ordering, with best and worst of those listed.
Related dot points
- Sorting algorithms: bubble sort and insertion sort and their quadratic efficiency, merge sort and quick sort and their use of divide and conquer, and comparing sorting algorithms by time complexity and stability.
An Eduqas Component 1 answer on sorting: how bubble and insertion sort work and why they are quadratic, how merge sort and quick sort use divide and conquer to reach n log n, and comparing the algorithms by time complexity.
- Searching and traversal algorithms: linear search and binary search with their conditions and efficiency, and the breadth-first and depth-first traversals of trees and graphs.
An Eduqas Component 1 answer on searching: how linear search and binary search work, the precondition that binary search needs sorted data, their time complexities, and how breadth-first and depth-first traversals explore trees and graphs.
- Dynamic data structures: stacks (LIFO) and queues (FIFO) with their push, pop, enqueue and dequeue operations and pointer management, linear and circular queues, and singly and doubly linked lists with insertion and deletion.
An Eduqas Component 1 answer on stacks, queues and linked lists: LIFO and FIFO behaviour, push, pop, enqueue and dequeue with pointer management, the wrap-around in a circular queue, and inserting and deleting nodes in a linked list.
- Trees, graphs and hash tables: binary search trees and their traversals (in-order, pre-order, post-order), graphs as adjacency matrices and adjacency lists, and hashing for direct-access tables including collision handling.
An Eduqas Component 1 answer on trees, graphs and hash tables: binary search trees and in-order, pre-order and post-order traversals, representing graphs with an adjacency matrix or adjacency list, and hashing for fast direct access with collision handling.
- Procedural and object-oriented programming: subroutines (procedures and functions) with parameters and return values, and the object-oriented concepts of classes and objects, encapsulation, inheritance and polymorphism.
An Eduqas Component 1 answer on programming paradigms: procedures and functions with parameters passed by value or reference, and the object-oriented concepts of classes, objects, encapsulation, inheritance and polymorphism, with their benefits for large programs.