MathJax

Saturday, January 16, 2010

Visualization of Algorithms, how should it be ?

Last days, while I was teaching a student some sorting algorithms. I asked myself how can I explain it the easiest way. The evident solution was to use some visualization tips.
OK OK, I say some "InfoViz", but then, the big question would stay the same : HOW ?

According to the human-computer interaction course I have got, Humans don't react like machine, they should have "Mental Models" to manipulate information and resolve problems. We don't have one Human mental model but we are sure about some reactions.
According to (Philip Johnson-Laird, 1983), humans need examples to how a mathematical functions work (hmmm, we don't speak about math nerds here...), so when we see a formula, we need to play it on some examples in order to construct our mental model.


Visualization of BubbleSort algorithm on a sample data.

So, to understand an algorithm, we should see it running on a sample data step by step, and then we should select the best data to not fall in a trivial example and this is another problem...

But, why we don't add a step in between ?
We have the algorithm coded in some language in one side, and the algorithm running in the other side.
Maybe adding the visualization of the algorithm itself can help the reader constructing quickly his mental model and reducing the time needed to see the algorithm running on data.

Some people tried to visualize algorithms by translating loops directly using schematics like these :

Explaining the multiplication µAlgorithm inside the µProcessor and introducing the Booth Algorithm.



Another almost useless technique for visualization I have seen in a site


But can we mix the algorithm itself and the data manipulation in the same place ? I have produced this figure from my own thoughts but really, we should think in a new way than everybody is following.


Searching for a new and better figures to help construct quickly the mental model.


In the last figure, arrows explain movement, the limits are nicely seen and understood, and it is clear that the second variable start its position from i and not from zero.
Can we ameliorate this figure and prove this way of representation scientifically ?
Maybe it can be a good point to start from.
:)

1 comment:

Anonymous said...
This comment has been removed by a blog administrator.