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 40 to 55 minutes.

Series: H446 2.2.1 · Programming techniques, part 4 of 14.

Shared by Coding PathwayVerified teacher

  • 14 cells
  • About 45 minutes
  • CC BY-SA 4.0
  • Shared 31 Aug 2026
  • Updated 1 Oct 2026

Preview

The whole resource, exactly as a class sees it. Answers and marking are held back.

Recursion and iteration compared

The same problem can often be solved with recursion or iteration. Both versions must be correct, but they may differ in readability, memory use and call overhead. This worksheet compares those differences for the problem being solved rather than treating one technique as always better.

By the end, you will be able to

  • translate between recursive and iterative forms
  • match base cases with loop initialisation and termination
  • compare clarity, call overhead and memory
  • make a contextual recommendation with a trade-off

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.

Worked example
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 roleIterative role
base caseloop stopping condition and initial result
recursive parameterloop-control state
self-call with changed inputupdate before the next iteration
operation after a returned valueaccumulator update

Trace both supplied functions on [3, 5, 2]. They visit the same values and produce 10, but the recursive version retains active call frames while the loop retains an accumulator.

Use precise comparisons. 'The recursive code is shorter' should become 'this recursive version uses fewer lines'. 'Recursion takes more space' should become 'each active call stores a frame, so this version has higher memory requirements as the list grows'. These claims describe this implementation; they are not universal rules about every recursive and iterative solution.

Multiple choice1 mark

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.
Written answer4 marks

Compare the two supplied functions using the same two criteria: readability for this flat-list problem, and extra memory or call overhead as the input grows.

For each criterion, refer to both implementations and use precise wording such as call frames, accumulator or number of lines.

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.

Coding task4 marks
def count_down(n):
    pass

Translate 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.

Coding task4 marks
def count_down_iterative(n):
    pass
Written answer3 marks

A 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.

Fill in the blanks4 marks
Recursion creates function-call checkpoint gap 1, so it usually uses extra checkpoint gap 2. Iteration controls repetition with a checkpoint gap 3. A recommendation should depend on the problem and its checkpoint gap 4, not a claim that one technique is always best.

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.