Community resourceWorksheet
OCR H446 2.2.1 Recursion and iteration compared
Part 4 of 14 · H446 2.2.1 · Programming techniques
Once students can write both forms, H446 2.2.1 asks them to choose between them. Recursion and iteration are compared here on shared criteria, clarity and memory cost, with translation in both directions so the comparison rests on genuinely equivalent code rather than on preference.
Students will:
- map base cases, recursive parameters and returns onto their iterative equivalents
- explain why an iterative version may use less additional memory on a long list
- compare two supplied functions using clarity and overhead as common criteria
- convert an iterative routine into a recursive one that returns the same list
- recommend an approach for a nested structure of varying depth and state one trade-off
Inside: 7 explanation cells, 1 multiple-choice question, 1 fill-in-the-blanks cell, 2 written answers and 3 Python tasks. 20 marks, about 30 to 40 minutes.
Series: H446 2.2.1 · Programming techniques, part 4 of 14.
Shared by Coding PathwayVerified teacher
- 14 cells
- About 30 minutes
- CC BY-SA 4.0
- Shared 31 Aug 2026
- Updated 3 Sept 2026
Preview
The whole resource, exactly as a class sees it. Answers and marking are held back.
Recursion and iteration compared
A playlist traversal can use calls or a loop. Correctness alone does not decide which expression is clearer or less costly.
By the end, you will be able to
- translate between recursive and iterative forms
- match base cases with loop initialisation/termination
- compare clarity, call overhead and memory
- make a contextual recommendation with a trade-off
Reactivate: base case, recursive case and loop condition.
Worked comparison method
Compare like with like. For a flat list [3, 5, 2], both approaches visit three values and return 10. The recursive version expresses ‘current value plus the total of the remainder’, but retains one call frame per active call. The iterative version uses a loop and one running total.
This supports a qualified conclusion: the loop is simpler and uses less additional stack space for this flat list; a recursive structure may be clearer for a naturally nested problem. The problem and implementation decide the recommendation.
def total_recursive(values, index=0):
if index == len(values):
return 0
return values[index] + total_recursive(values, index + 1)
def total_iterative(values):
total = 0
for value in values:
total += value
return total
print(total_recursive([3, 5, 2]))
print(total_iterative([3, 5, 2]))Worked model: map equivalent roles
| Recursive role | Iterative role |
|---|---|
| base case | loop stopping condition / initial result |
| recursive parameter | loop-control state |
| self-call with smaller input | update before next iteration |
| returned combination | accumulator update |
Trace both supplied functions on [3, 5, 2]. They visit the same values and produce 10, but the recursive version retains calls while the loop retains an accumulator. Compare on a common criterion rather than writing disconnected advantage lists.
Why may the iterative version use less extra memory for a long flat list?
- AA loop never stores variables.
- BRecursive calls may retain separate stack frames.
- CIteration automatically compresses the list.
- DA return statement copies the whole program.
Compare the two supplied functions using clarity and memory/overhead as common criteria.
Discuss both implementations under each selected criterion.
Students type their answer here.
Translate iteration to recursion
Write a recursive function count_down(n) that returns a list [n, n-1, ..., 1]. For n <= 0 it returns an empty list.
def count_down(n):
passTranslate recursion back to iteration
Create the same returned list without self-calls. Map the base-case result to the initial empty list and the decreasing recursive parameter to loop-control state.
def count_down_iterative(n):
passA nested menu contains submenus of the same structure, but its depth varies. Recommend recursion or iteration and justify your decision, including one trade-off.
Use the natural shape of the problem and one implementation cost.
Students type their answer here.
Checkpoint
Complete the comparison from memory. There is no answer bank, and correctness is withheld until teacher review.
Review your understanding
Before submitting, check that you can explain the main distinction in your own words, apply it in an unfamiliar context and justify the resulting behaviour or consequence.