Information Technology Reference
In-Depth Information
12.4.2
The “Top-Down Frames” Model
The little people metaphor is an excellent pedagogical tool for illustrating the ex-
ecution of recursive methods; individual learners, however, cannot carry it out in
their notebook by their own. The following model—the top-down frames model—
overcomes this limitation of the little people model by enabling each learner to trace
the recursive process by her or his own.
This model guides learners, on each level of the recursion, to write all the in-
structions that should be executed (one after another), where for each recursive
call a new box is opened, until all the boxes are embedded in the initial method
invocation (see Fig. 12.1 ).
Once all the boxes are embedded with all the details, the (printing) instructions
can be executed (see Fig. 12.2 ).
It is important to note that unlike the little people model, the top-down frames
model does not emphasize all the issues of the recursive process (the returning
process, for example, is not strongly demonstrated here); it is, however, helpful to
use this model as a tracing tool in learners' notebooks. It is also important to supply
the learners with different models to support their learning of the recursive process.
In the MTCS course, after the instructor explains the top-down frames model,
the students are asked to trace by their own another recursive method/program, for
example, the following recursive_magic (1, 3) method.
public static void recursive_magic (int a, b) {
if (a==b)
System.out.println (“finished”);
else {
System.out.println (a);
recursive_magic (a + 1, b);
System.out.println (a);
}
}
It is recommended to discuss with the students the differences between recursive
methods, which do not return a value (i.e., in Java, they return void ), and recursive
functions (i.e., methods that return a value). The recursive examples presented here
are methods that do not return a value. It is recommended to demonstrate the two
models on a recursive function (e.g., Fibonacci), emphasizing what a little person
does with the returned values when he or she finishes his or her job.
Clearly, additional tracing models are presented in the literature. The students can
be asked to find additional tracing models by using the web (looking, for example,
for tracing demonstrations in YouTube). It is important to emphasize criteria of
good models; in the case of tracing recursion, for example, one such criterion is that
Search WWH ::




Custom Search