# Encyclopedia of Mathematics Education

Living Edition
| Editors: Steve Lerman

# Algorithms

• Mike O. J. Thomas
Living reference work entry
DOI: https://doi.org/10.1007/978-3-319-77487-9_8-2

## Keywords

Algorithm Computing History of mathematics Instrumental understanding Representation

## Definition

The word algorithm probably comes from a transliterated version of the name al-Khwarizmi (c. 825 CE), the Arabic mathematician who described how to solve equations in his publication al-jabr w’al-muqabala. An algorithm comprises a step-by-step set of instructions in logical order that enable a specific task to be accomplished. Due to its nature, it can be programmed into a computer, although some problems may not be computable or solvable by an algorithm. In his famous paper, Turing (1936) showed, among other things, that Hilbert’s Entscheidungsproblem can have no solution. He did this by proving “that there can be no general process for determining whether a given formula U of the functional calculus K is provable, i.e., that there can be no machine which, supplied with any one U of these formulae, will eventually say whether U is provable” (1936, p. 259).

An example of a simple well-known algorithm is that for sorting a sequence of real numbers into descending (or with a minor change, ascending) order, sometimes called a bubble sort. In this we perform something similar to the following steps, which describe the algorithm:
1. 1.

Set the count to 0.

2. 2.

Compare the first two numbers a1 and a2 in the sequence. If a1 < a2 then swap a1 and a2 and add 1 to the count. If a1 > a2 then proceed directly to step 3.

3. 3.

Compare the numbers a2 and a3 in the sequence and repeat as in step 2.

4. 4.

When the last two numbers in the sequence have been compared, consider the count of the number of changes. If the count is zero, then the sequence is sorted into order. If the count is greater than zero, repeat from step 1.

We note that two algorithms to accomplish the same task may vary or be entirely different. For example, there are a number of different algorithms for sorting numbers into order, often much more efficiently than the bubble sort, such as the quicksort algorithm.

Another common example referred to as the Euclidean algorithm for finding the greatest common divisor (gcd) of two integers n and m may be stated as:
1. 1.

If n = m then output n as the gcd (n, m) and end.

2. 2.

If n > m the initialize a = n and b = m. Otherwise, initialize a = m and b = n.

3. 3.

Apply the division theorem to a and b by finding integers q and r such that a = q.b + r, where 0 ≤ rb.

4. 4.

If r = 0 then output b as the gcd (n, m) and stop. Otherwise set a = b and b = r. Go to step 3.

Based on Khoussainov and Khoussainova (2012), p. 29.

In this case we illustrate how algorithms to accomplish the same task may be equivalent but presented differently and thus not necessarily appear to be the same. Consider, for example, a second version of the Euclidean algorithm (based on the version found at http://sites.math.rutgers.edu/~greenfie/gs2004/euclid.html):
1. 1.

If m < n, exchange m and n.

2. 2.

Divide m by n and get the remainder, r. If r = 0, report n as the gcd.

3. 3.

Replace m by n and replace n by r. Return to the previous step.

What do we notice about these two versions? While they are the same algorithm, that is, they accomplish the same task in the same way, the first one appears more complex. This is because it uses function notation (gcd (n, m)); it is not self-contained but refers to a previous result (the division theorem); and it introduces more variables (an extra a, b) than the second. These differences may be the result of attempts to be rigorous or to make the algorithm more amenable to computerization.

It is perfectly possible to be able to carry out an algorithm, such as the quicksort or Euclidean algorithms above, without understanding how it works. In this case an individual would demonstrate what Skemp (1976) called instrumental understanding, whereas knowing the reasons why it works would constitute relational understanding. It would also be a mistake to think that mathematics may be reduced to a series of algorithms. The idea of an algorithm is closely related to what, in mathematics education terms, are often called procedures, since these may be accomplished using algorithms. They contrast with other crucial elements of mathematics, such as objects, constructs, or concepts. While both procedures and concepts are important in learning mathematics (Hiebert and Lefevre 1986), teaching algorithms is often easier than addressing concepts, and so this approach may prevail in school (and sometimes university) teaching. For example, the formula for solving a quadratic equation ax2 + bx + c = 0 with real roots $$x=\frac{-b\pm \sqrt{b^2-4 ac}}{2a}$$ leads to an algorithm for solving these equations. However, it may be the case that students who can successfully find the roots of a quadratic equation ax2 + bx + c = 0 only have instrumental understanding and do not understand well why the formula works, what an equation is (Godfrey and Thomas 2008), or even what a solution of an equation is. They may not appreciate, for example, that the formula arises from completing the square on ax2 + bx + c = 0; that if p and q are real roots of ax2 + bx + c = 0, then ap2 + bp + c = 0 and aq2 + bp + c = 0 by definition; and that a factorization of the form ax2 + bx + c = a(xp)(xq)[=0] is possible.

One drawback of the step-by-step nature of an algorithm is that it leaves no room for deviation from the method. Hence, it cannot encourage or promote the versatile thinking (Thomas 2008; Graham et al. 2009) that is needed in order to understand some mathematical constructs and hence to solve certain mathematical problems. For example, it may be both useful and enlightening to switch representations or registers to comprehend an idea better (Duval 2006) or to view a written symbolism (described as a procept) as either a process or an object (Gray and Tall 1994) depending on the context. One example of this is appreciating the relationship between the roots of the quadratic equation above and the graph of the function. Another is the calculation of integrals through the use of limits of Riemann sums. Algorithms can be constructed for processes that allow students to find a Riemann sum or its limit, but there is evidence that far fewer students understand the nature of the limit object itself (Tall 1992; Williams 1991).

## References

1. Duval R (2006) A cognitive analysis of problems of comprehension in a learning of mathematics. Educ Stud Math 61:103–131
2. Godfrey D, Thomas MOJ (2008) Student perspectives on equation: the transition from school to university. Math Educ Res J 20(2):71–92
3. Graham AT, Pfannkuch M, Thomas MOJ (2009) Versatile thinking and the learning of statistical concepts. ZDM Int J Math Educ 45(2):681–695
4. Gray EM, Tall DO (1994) Duality, ambiguity and flexibility: a proceptual view of simple arithmetic. J Res Math Educ 26(2):115–141Google Scholar
5. Hiebert J, Lefevre P (1986) Coneceptual and procedural knowledge in mathematics: an introductory analysis. In: Hiebert J (ed) Conceptual and procedural knowledge: the case of mathematics. Erlbaum, Hillsdale, pp 1–27Google Scholar
6. Khoussainov B, Khoussainova N (2012) Lectures on discrete mathematics for computer science. World Scientific, Singapore
7. Skemp RR (1976) Relational understanding and instrumental understanding. Math Teach 77:20–26Google Scholar
8. Tall DO (1992) The transition to advanced mathematical thinking; functions, limits, infinity, and proof. In: Grouws DA (ed) Handbook of research on mathematics teaching and learning. Macmillan, New York, pp 495–511Google Scholar
9. Thomas MOJ (2008) Developing versatility in mathematical thinking. Mediterr J Res Math Educ 7(2):67–87Google Scholar
10. Turing AM (1936) On computable numbers, with an application to the Entscheidungsproblem. Proc Lond Math Soc 42(2):230–265Google Scholar
11. Williams SR (1991) Models of limit held by college calculus students. J Res Math Educ 22:237–251