Data Structure Visualization with LaTeX and Prefuse Ali Erkan * Ithaca College 1212 Williams Hall Ithaca, NY 14850, U.S.A. aerkan@ithaca.edu T.J. VanSlyke † Ithaca College Ithaca, NY 14850, U.S.A. teejay.vanslyke@gmail.com Timothy M. Scaffidi, ‡ Ithaca College Ithaca, NY 14850, U.S.A. tscaffi1@ithaca.edu ABSTRACT We report two ways with which data structures as well as their algorithmic operations can be visualized. The first method uses L A T E X to automatically generate diagrammatic presentation material from extended versions of the Java implementations of well-known ADTs. The second method uses the Prefuse API to explore objects created in running Java programs. Categories and Subject Descriptors E.1 [Data Structures]: Lists, stacks, and queues, Trees, Graphs and networks. General Terms Algorithms, experimentation. Keywords Data structures, algorithms, visualization, Java program- ming, L A T E X, Prefuse, AspectJ. 1. INTRODUCTION One of the luxuries of teaching a data structure or an al- gorithms course is the extent to which the underlying prob- lems can be diagrammatically illustrated. While formalism, pseudo-code, and proofs make our arguments more robust, diagrams provide an intuitive understanding and help stu- dents see the big picture. Most textbooks utilize this fact and provide detailed figures to accompany textual explana- tions. The World Wide Web does its share of visual con- tributions as well, with the countless sites that provide dia- grams and animations to better illustrate the data structure and algorithmic processes. * Assistant Professor of Computer Science. † Computer Science B. A. ‡ Computer Science B. A. Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To copy otherwise, to republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. ITiCSE’07, June 23–27, 2007, Dundee, Scotland, United Kingdom. Copyright 2007 ACM 978-1-59593-610-3/07/0006 ...$5.00. One of the more convincing examples of the benefits of “seeing” can be found at Jason Harrison’s web page that contains applets to compare the operation of sorting algo- rithms 1 . These applets are good at grabbing student atten- tion. However, far from being eye candy, they also allow the instructor to point out, for example, the fundamental operational difference between the O(N 2 ) and O(N lg N ) families of sorting techniques. Another notable example is the balanced tree animations from Jorge Riera’s web page 2 . In this paper, we report the development of two schemes for visualizing data structures to better explain their algo- rithmic operations. We start with an overview of some of the related published work (section 2). We outline a L A T E X based method to produce detailed presentation material from the Java implementations of ADTs frequently encountered in CS2 and CS7 type courses (section 3). We then describe a recent project where we use a visualization API called Prefuse (released from UC Berkeley in 2006) to create a less restricted picture of the objects in a program (section 4). We conclude the paper by enumerating some of our future goals (section 5). 2. RELATED WORK For over a decade, algorithm/data-structure visualization has been an active research area in computer science educa- tion; for a partial list of representative projects, please refer to [12, 6, 10, 9, 2, 1, 5, 7] and check the “SIGCSE: Educa- tion Links” page 3 . In his Ph.D. dissertation, Roessling cites several of the methods that have been tried in the past [8]. Since the design of visualization systems is not purely a mat- ter of science, some researchers have supported the idea that topic-specific animations lead to the most effective solutions (e.g. Kucera [3]). Given the difficulty of the “one solution for all” problem, numerous API-based solutions have been designed. Systems to produce visualizations by code inter- pretation have also been proposed. 3. L A T E X BASED VISUALIZATIONS We have experimented in developing a L A T E X-based scheme to produce instructional materials, which have serendipi- tously worked out as an example of visualization through code interpretation. During the past three years, many of the data structure and algorithms lectures of the first au- thor have evolved into a format where the presentation starts 1 http://www.cs.ubc.ca/˜harrison/Java/sorting-demo.html 2 http://webpages.ull.es/users/jriera/Complejidad.htm 3 http://www.sigcse.org/topics 301