next up previous
Next: Discussion Up: A Pre-Programming Introduction to Previous: Outline of the course

The multi-layered chart

Since no programming language is used throughout the course, a good way of representing algorithms has to be chosen. There are some well known and widely used tools for representing algorithms, let us very briefly describe two of them, which have become sufficiently well known to make it unnecessary to dwell upon here.

We chose to introduce a visual presentation, a multi-layered chart. The idea underlying this type of multi-layered chart, is to maintain the hierarchical structure of an algorithm. The professional literature is familiar with a wide spectrum of hierarchical charts, from the Nassi-Shneidermann diagrams [NAS] to higraphs introduced by Harel [HAR].

"Our" chart is supposed to give a quite full and good description of all the components of an algorithm. It is composed of layers, where the first one gives the top design of the algorithm, and the other layers describe the more refined details, mirroring the stepwise refinement process.

Special boxes are used to describe the beginning and the end of an algorithm, other boxes are used for assignment statements, for input and output statements, for conditions, loops, and for procedures. We will not go into the details of describing each box and explaining what it stands for, this of course should be done in class. However, Figure 1 and Figure 2 which are self-explanatory, show all the elements needed to draw a multi-layered chart of an algorithm.

Figure 1 is a multi-layered chart of an algorithm that calculates and prints the well known Fibonacci series (i.e. $f_{n}$, such that $f_{n+1}=f_{n}+f_{n-1}, n>0$). The algorithm gives all the Fibonacci numbers that are smaller than a given $n$. The chart has four layers. The first layer gives the main procedures: input, initialization, and compute -- the computation of the new Fibonacci number. The second layer describes the procedures in more details. One of the procedures -- compute -- invokes another procedure -- next element -- which is given in detail in a third layer, and which in turn invokes the procedure output, that is given in the fourth layer.

The chart provides an overall look of the algorithm. Each layer and each procedure can be viewed in detail. One can zoom into the procedure compute for example, which is drawn in the second layer. The heart of procedure compute is a while loop. While $f_{2}$ is smaller than n, next Fibonacci number has to be computed, so procedure next element is invoked. When $f_{2}$ becomes equal to or greater than n, control is returned to the calling procedure (which is the main program in this case).

Figure 2, is a multi-layered chart of an algorithm that solves a quadratic equation, i.e. $ax^2+bx+c=0$, or linear equation, i.e. $bx+c=0$. This chart has three layers, the first gives the outline of the algorithm, and the other two the refinement of it. The branching structure which is very well distinguished from the sequential structure, plays here an important role.

We think that this chart has many pedagogical advantages:

When presenting multi-layered charts to a class, different colors can be used for each different layer. This will make the description even more vivid.

However, this visual tool sets some practical limitations. The gain in overview may be lost if there are too many layers. The layout of the chart may become very cumbersome; it will probably be a multi-page layout chart, and will not achieve its goal of producing a clear visual representation of the algorithm. Some suggestions to overcome this, are given in the discussion section. However, we feel that this practical problems limit the use of the multy-layered chart to simple problems of the kind we meet in introductory courses. This is where the advantages of the chart are the greatest, and thus achieves our aim.


next up previous
Next: Discussion Up: A Pre-Programming Introduction to Previous: Outline of the course
2004-01-06