• No results found

Recursion vs Iteration

In document Modelling recursion (Page 56-61)

2. Review of the Literature

2.3. Students‟ Difficulties with Understanding Recursion

2.3.6. Recursion vs Iteration

The relationship between recursion and the concept of iteration is another crucial aspect of the concept of recursion which is going to be discussed in this section. Distinguishing between iteration and recursion is one of the most common difficulties that students have in understanding and applying recursion and it is one that many researchers have studied (Wanda, 2001; Ginat and Shifroni, 1999; Turbak et al, 1999; Harvey, 1997; Wiedenbeck, 1988; Anazi

and Uesato, 1982; Kurland and Pea, 1985). An iterative process is an accumulation process; one stage starts after the previous stage ends. In contrast, recursion is a process where one procedure (as a sub-procedure of itself) begins and ends before its previous procedure ends. Turbak et al, (1999) also explain a syntactical difference between loops and iterations:

“We use „iteration‟ to describe a step-by-step computational process that determines the next values of a set of state variables from their previous value. A „loop‟ is a particular control structure, denoted by special syntax, for expressing iteration, such as Java‟s WHILE and FOR constructs.” (p. 86)

The following programs calculate the factorial of a natural number „n‟ first iteratively and then recursively.

To iterative-factorial :n Make “I 1

Make “n! 1

While [ :I < n + 1 ][ make “I I + 1 :n! = :n! * I ] (The repeating part)

Output :n! End

To recursive-factorial :n If :n = 0 [ output 1]

Output :n * recursive-factorial :(n – 1) (The recursive call)

End

Program 4- A recursive Logo program to calculate factorial of a natural number „n‟

They also stated that iteration is a tail recursion. For them, iteration is a particular pattern of recursion:

“[…] all iterations are expressed via tail recursion, a particular form of recursion.” (p. 88)

The influences of iteration and recursion have been of interest to many researchers. Anazi and Uesato (1982) argue that having a prior understanding of iteration facilitates a deeper understanding of recursion. They worked with 88 students in two groups of iterative–recursive and recursive–iterative. Their research shows that 64% of the students who had prior experiments with iteration were able to formulate the factorial function recursively. However, only 33% of the students with no prior experiments with iteration were able to implement the factorial function recursively. They therefore conclude that:

“Recursive procedures may be acquired based on learning of

They also make the point that the above conclusion is based only on an appreciation of factorial function as a mathematical definition, not as a computer program:

“We should be cautious when we try to extend the consideration to more complex domains such as computer programs.” (p. 102)

Wiedenbeck (1988) criticized their work by using the factorial function (mathematical view). She repeated their study by adding two more groups of iterative – iterative and recursive – recursive. Wiedenbeck‟s results did not support Anazi and Uesato‟s study. However, she carried out another study using computer programs instead of a mathematical approach. Wiedenbeck concluded in the case of computation that having prior experience of iteration facilitated understanding recursion. Further support for Wiedenbeck‟s results has been presented in Kessler and Anderson (1986). They focused on transferring skills between performing iterative and recursive procedures. They conclude that although writing procedures on iterative and recursive functions does not facilitate writing procedures on recursion functions, having prior experience of similar iterative procedures enabled increased sophistication in dealing with “flow of control”, which is needed for understanding recursion.

The flow of control is deliberated in the next section. Kessler and Anderson (1986) also claim that this result occurs because students have developed a weak mental model of recursion, and this poor mental model of recursion

hampers their study of iteration. Mental models of recursion will also be discussed later in this chapter.

Ginat and Shifroni (1999) stated that discovering iteration is much easier than recursion. They also explained that although decomposition of a problem into its sub-problems of the same kind is logically coherent, it is not easily understood by learners. Another learning difficulty which is related to the composition of solutions to sub-problems is to achieve a global solution for the original problem. Kurland and Pea (1985) explained that most of the students view all forms of recursion as iteration. Some researchers believe that the functioning of tail recursion is easier than embedded recursion (Leron and Zazkis, 1985; Wiedenbeck, 1988; Turbak et. al, 1999):

“Recursion may be learned gradually, by bits, starting from graphics-based tail-recursion.” (Leron and Zazkis, p. 28)

Turbak et al. (1999) also pointed that iteration is easier than recursion:

“Iterations expressed via tail recursion are often easier to read, write, and reason about than loops. The rigid structure of looping constructs makes it tricky to express iterations that may terminate under multiple conditions, especially if some of the conditions occur in the middle of a loop body or require finalization actions”. (Turbak et al, p. 89)

Turbak et al, also add that:

“The tail recursive approach is expressible in all general- purpose programming language.” (ibid., p. 90)

Harvey (1997) points out that in iteration the procedure always repeats a certain number of commands without any changes, whereas in recursion, the procedure itself is called by one of the recursive calls with some new initial values.

The literature that has been reviewed thus far demonstrates the problematic inter-linkage between the two concepts of iteration and recursion, which needs to be focused on from a closer perspective. My conjecture is that by comparing and testing the similarities and differences in tail recursion and iteration, we can reduce students‟ problems with embedded recursive procedures.

In document Modelling recursion (Page 56-61)