Past-paper question · 2012 May-June · Paper 21 · Q5(d)

Question 5(d) 2012 · May-June · Paper 21 · 4 marks

Original past-paper question for 5(D)
Original past-paper question for 5(D)
Original past-paper question for 5(D)
Original past-paper question for 5(D)
Reveal official mark-scheme answer Official mark-scheme answer for 5(D)

Official answer for Question 5

Part (d)

Part (d)

  • FOR loop usually simpler to understand
  • usually simpler to write
  • iteration less chance of error
  • large number of function calls could cause stack overflow
  • ... this is not a problem for small values of Num
  • recursion could be quicker
  • recursive solution is a more elegant solution
[4]
✓
© University of Cambridge International Examinations 2012

Mark scheme 9691_s12_ms_21.pdf →

Show text version of question

Question 5

Part (d)

Question 5

Romana is learning about recursion. She designs a recursive function. For

Examiner's 01 FUNCTION Happening(Num) Use

02 IF Num = 1 03 THEN 04 Happening ← 1 05 ELSE 06 Happening ← Happening(Num - 1) + Num 07 ENDIF 08 ENDFUNCTION

Part (d)

The same process could have been solved iteratively using a FOR loop.

Discuss the merits of iterative and recursive solutions to this problem, particularly when the initial value of Num is very large.

[4]

Question 12

reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the publisher will be pleased to make amends at the earliest possible opportunity.

University of Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.

Topic relevance

Why this question appears here

98% assigned-topic match · Computational thinking and problem-solving › Recursion

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 9691_s12_qp_21.pdf

Keep practising this topic