I find the introductory example overly compley and, well, wrong. You do not specify in which direction the digits are read, you could just as well read the digits from A from left to right and the ones from B from right to left. You refer to the "end" - but there are two ends, which one.
Why not take an everyday algorithm, such as making pasta with tomato sauce (this introduces a parallelism, which might not be wanted), or knitting a sweater? It is too late in the evening to do so now, but this needs fixed. --WiseWoman 22:33, 17 October 2006 (UTC)
A good illustration of algorithms is the problem of pairing socks (a lecturer of mine acctually brought a large bag of socks in the first two lecturers of a module on performance of algorithms). I thought this is useful for introducing many of the concepts of space- and time-complexity of algorithms. --CrazyTalk
I removed this (as suggested by WiseWoman)[edit source]
(This was replaced by the Toast example I wrote. feel free to switch them back around)
You have probably been taught as a young child in school how to add two numbers on a piece of paper: add each pair of digits, as well as the carry value. A way to write this in a stricter, computer-like language may be as follows:
input A, B for each digit a in A, digit b in B set temporary digit to a + b + carry if temporary digit >= 10 reduce temporary digit by 10 set carry to 1 otherwise set carry to 0 end if add temporary digit to end of result end loop if carry = 1 add carry digit to end of result end if