Visual Representations for Recursive Algorithms

L. Stern and L. Naish

Proceedings of the 33rd Annual SIGCSE Technical Symposium on Computer Science Education, ACM Press, 196--200, 2002.

We have developed a framework for pedagogically-oriented animations, designed to help students learn new algorithms. Recursive sorting and searching algorithms pose a particular challenge, as it can be difficult to find visual representations that help students develop a mental model of how the recursion proceeds. Relatively complex representations, such as thumbnail sketches or explicitly showing the function stack along with the data structure are appropriate for some algorithms, while simpler representations suffice for others. We have found it useful to classify recursive algorithms according to the way they navigate through a data structure and manipulate data items within it, sometimes with further subdivision according to the kind of recursion. Within each category there are common strategies for visual representation. While there may be no single, general way to represent recursive algorithms, classification is a useful guide to picking an appropriate strategy when animating recursive algorithms.