The World Of Algorithms
(i) Add and using the steps we have written down. Make sure you follow the steps precisely; do not perform any action that is not explicitly mentioned. Are you able to obtain the correct result?
What happens if you add a ‑digit number to a ‑digit number? Do our steps handle this situation correctly?
Why is it important to align the columns from right to left?
In Step 3, why cannot the value of carry be more than 1?
What happens if we do not include the fifth step in the algorithm above? Give examples where the algorithm will work correctly and where it will fail to work. There is also an important assumption in this algorithm, namely, that we know how to add single digit numbers without counting them out. Typically, any algorithm is built using such basic steps that we assume we can perform directly. The main advantage of this algorithm is that it is much faster than counting explicitly. For instance, if we move from adding 3-digit numbers to adding 4-digit numbers, we have 10 times as many dots to draw and count. On the other hand, if we add the digits right to left, as in the algorithm above, we only have to add 1 more column. Likewise, 5-digit numbers would generate 100 times as many dots as 3-digit numbers, but only 2 more columns to be added. In concrete terms, suppose we can count one dot per second. To count the dots in would take a minute, to count would take about ten minutes, while would take over one hour and forty minutes. On the other hand, suppose we work slowly and carefully and take 15 seconds to add two single digit numbers with a carry. Adding would take about half a minute, while would take about 45 seconds, while would take about one minute. Whenever we provide an algorithm, we also have to justify why it works. Combining the dots and counting the sum is how addition is defined. Why does adding individual digits from right to left result in the sum of the two numbers? The key idea is that we are grouping each number into units, tens, hundreds, … and adding each group separately. Whenever a smaller group, say units, generates a large group of ten, we carry over the newly formed ten to the tens group.