Next:Languages
Up: Overview
Previous: Introduction
Algorithms
Why Teaching Algorithms First is Not the Right Thing
Algorithms are fundamental to Computer Science, that is for sure. But, on the other hand, the Fundamental Theorem of Algebra is fundamental to algebra, yet is not a good place to begin teaching it. Clearly, fundamental is not synonymous with a good foundation.
The problem with teaching algorithms first thing is that the definition of algorithm is ambiguous without a vocabulary upon which to lay it. Asking for an algorithm to solve some particular problem does not clarify what exactly is needed, unless there is some given language or notation in which the algorithm can be expressed. For example, suppose one wants an algorithm for adding two numbers together.
The follows solutions might be produced- c = a + b
- If the vocabulary is C/C++ or any Von Neumann language
- take the rightmost two digits, add them together and compare the result to the radix, repeating with a carry if needed
- If the vocabulary is grade school arithmetic
- take the rightmost two bits, AND them together for the carry, also AND the OR of these bits with the NOT'd AND of the same bits...
- If the vocabulary is binary logic gates
- subtract 1 from b and add 1 to a. repeat this until b is 0
- If the vocabulary is Turing Machines
Clearly these are all technically "algorithms", but the educational value provided by these answers is questionable. Without restricting the problem domain, nearly anything could be considered a correct algorithm, which begs to question what exactly is gained by producing such obvious formulations.
Algorithms are a very powerful tool when used correctly. But like most powerful tools, they are best learned not from the start, but slowly over time, so that the student has become acclimated to environment in which they are used. Only then will it become clear what their purpose is, and how best to use them to create general solutions to specific problems.
Even with a well-defined vocabulary, it is not in the student's best interest to immediately move on to algorithms. An important property of an algorithm is that it is supposed to be generic enough to work on any possible input. However, being able to judge something as sufficiently generic requires well-developed skills. At first, a student should only learn how to solve a problem for some subset of reasonable inputs. Perhaps three or four sample inputs should work correctly. After a student has mastered working with these problems, they should introduced to border cases. By combining the common solution with the border case solutions, the general algorithm can be made. However, doing so requires the student already knows control structures well enough.
As such, after learning about the vocabulary, students will be taught about composition. The concept here is to get them used to combining simple, atomic instructions to perform more complex operations. These will be primarily arithmetic operations, though getting conversational input and output to work will also be an option. These compound operations will be required to work for a reasonable set of inputs, but not for any possible values, in order to allow us to ignore overflow, null strings, etc.
Next:Languages
Up: Overview
Previous: Introduction
by dlong@progmatism.com. Plz don't copy kthx.