Logout

D.4.4

Trace recursive algorithms.

 

Teaching Note:

All steps and calls must be shown clearly.

LINK Connecting computational thinking and program design.

 

Sample Question - FORMER CURRICULUM - Not so much tracing, but a good overall recursive question.:

Given a program which functions like a linked list and has a recursive count method (HL 2 May 2008, question 1):

(e) State the name of the programming technique used in the countUp method used
in the List class. [1 mark]

To use this method the following statement is used.
output(list.count());

(f) State the sequence of steps that flow from executing the above statement and
state clearly how the count method stops executing. [4 marks]

 

Sample Question - FORMER CURRICULUM:

Consider the following recursive algorithm.

  int recur(int b)
{ if (b==0)
return 1; else return 2*recur(b-1); }

(a) State two features of a recursive algorithm. [2 marks]
(b) State the value returned if the method is called by recur(3). [2 marks]

JSR Notes:

Refer back to 5.1.1, 5.1.2, and 5.1.3 and the links therein.