![]() |
Abstract 1. Introduction This paper describes a project to develop a visualization of the algorithms for implementing methods of the Java LinkedList class. This visualization will serve as a prototype for visualization of any Java Collection Class. The Java Collection classes consist of a hierarchy of interfaces and classes representing Abstract Data Types (ADTs), originating with the Java Collection interface. These classes each consist of an API containing the methods of the class, but are relatively independent of the implementations. The prototype, called JVALL (Java Visual Automated Linked List), was developed as an extension of the Java LinkedList class. The approach used here is similar to that used by Jeliot [5,6], where a user-written Java program is submitted to the Jeliot server, which produces an animation of operations that the submitted code performs on a data type. Jeliot provides animations for all Java primitive types, arrays, stacks, and queues. The JDSL Visualizer [7] also uses this approach by providing the application programmer interface (API) for abstract data types and automatically generating visualizations. The APIs of JDSL, however, do not conform to Java Collection Class APIs. Many researchers have conducted studies of the effectiveness of visualizations for the learning of algorithms and data structures. These studies have produced mixed results and have led some to question the validity of visualization as an aid to learning in this context. A recent meta-study [8] examines many earlier studies and identifies factors that the earlier studies have empirically agreed lead to successful visualizations. We have utilized these results in the design of JVALL. The following are four features that we believe are key to successful visualizations and that we have attempted to provide in this prototype:
|
|
![]() |
![]() ![]() 2. Three Aspects
of Abstract Data Types
A second important aspect of ADTs is their application. This requires an understanding of the ways an ADT is used, in what situations its use is advisable, and how it is used effectively in those situations. The final aspect is the implementation. This includes the data structures used to represent the ADT, the algorithms used to implement its methods, and techniques for careful space and time analysis of those algorithms. JVALL has been developed to support all three of these aspects of learning an ADT, in particular, the list ADT as represented by the Java LinkedList class. The JVALL class has an API that is identical to that of the Java LinkedList class, thus supporting the learning of the conceptual view represented by this Java collection class. Since JVALL can be used in any context where the LinkedList class is used, it provides an efficient way to understand applications of the ADT through visualization, whether the application is student-written or provided by the instructor. Finally JVALL provides views of multiple implementations of the ADT, giving the student a means to carefully examine the implementation visually. In particular, when used with a source-level debugger, JVALL can enhance the student's ability to perform time and space analysis. |
![]() |
![]() |
3. JVALL Overview
and Objectives |
![]() |
|
![]() Figure 1. Model-view-controller view of JVALL. |
![]() |
![]() Typical to the MVC framework, JVALL supports multiple controllers and multiple views through a single model, the linked list ADT. A controller may be any class that uses the linked list ADT. It may be a specially designed interactive instructional module, a class implementing another ADT that uses the linked list such as a stack, or any other application, complex or simple, that uses one or more linked lists. The controller may interact with a user, such as the student or the instructor, it may run under file control, or it may be an application with no input at all. There are also multiple views that represent multiple implementations of the ADT. In the current system, only two implementation views are provided for the linked list ADT, the linear, singly-linked and the circular, singly linked implementations. Others will be provided in the future. The user also interacts with each view, controlling the visualization's color scheme, speed, and direction (through an undo/redo facility). The JVALL class itself is the LinkedList model that implements the underlying Java collection class and interfaces with the multiple controllers and views. The objective of this project is to produce a linked list visualization tool that provides a prototype for further development and has the following capabilities:
4. A Simple Example |
![]() |
![]() |
![]() import jvall.Jvall; import jvall.JvallListener; import java.util.ListIterator; public class JvallTest implements JvallListener { public static void main(String[] args) { Jvall myList = new Jvall(Jvall.STANDALONE); JvallTest myTest = new JvallTest(); myList.addAnimationListener(myTest); myList.addFirst("One"); myTest.waitForJvall(); myList.addLast("Three"); myTest.waitForJvall(); myList.add(1,"Two"); myTest.waitForJvall(); myList.set(myList.indexOf("Two"),"TWO"); myTest.waitForJvall(); ListIterator myIterator = myList.listIterator(0); while (myIterator.hasNext()) { System.out.println(myIterator.next()); } } public JvallTest() { this.done = true; this.status = "Uninitialized"; } public synchronized void waitForJvall() { while (!this.done) { try { wait(); } catch (Exception e) {}} } public synchronized void animationEvent(int event) { if (event == Jvall.ENDED){ this.done = true; notify(); } else if (event == Jvall.RUNNING) this.done = false; } public void statusUpdate(String strStatus) { this.status = strStatus; } private boolean done=true; private String status; } |
![]() Figure 2. A simple example program using JVALL. |
![]() |
![]() The Jvall class (which implements the JVALL ADT) has the same API as the Java LinkedList class except for the inclusion of a constructor that takes a single parameter that specifies whether the JVALL will run as a Java application or an applet. Also, the addAnimationListener method enables a JvallListener to be attached to the JVALL linked list. JvallListener is an interface with two methods: public void AnimationEvent(int event); public void statusUpdate(String strStatus); JvallListener provides communication from the view to the controller with the model serving as an intermediary. This allows the animation to communicate with the controller without knowledge of the details of the controller's implementation. The two possible event parameters that can be sent to AnimationEvent are Jvall.ENDED and Jvall.RUNNING. These two int constants indicate that the animation has finished or begun running. Whenever the status of an animation is changed, the statusUpdate method is called and the String that appears in the status textfield of the animation will be the strStatus parameter. In the case of the program in Figure 2, the instantiation of statusUpdate is public void statusUpdate(String strStatus) { this.status = strStatus; } This will set the instance variable status to the String that is returned to this class by the view. That String will correspond to the String that appears in the TextField labeled "Animation Status" in the animation view window. In the example in Figure 2, JvallTest is also a JvallListener. It sets its instance variable done whenever the running state of the animation changes. It also keeps the latest status of the animation in instance variable status. The method waitForJvall waits for a notification that a visualization that is active has been completed. public synchronized void waitForJvall() { while (!this.done) { try { wait(); } catch (Exception e) {}} }This is called following every JVALL method call so that the program will not proceed until the animation process is completed. Three nodes are added to the JVALL linked list, one is changed, and then an iterator is created that iterates through the list, printing each node. This is accomplished in the main program through the calls myList.addFirst("One"); myTest.waitForJvall(); myList.addLast("Three"); myTest.waitForJvall(); myList.add(1,"Two"); myTest.waitForJvall(); myList.set(myList.indexOf("Two"),"TWO"); myTest.waitForJvall(); The interspersed waitForJvall() calls require the program to wait for the completion of the visualization before proceeding to the next operation. The output produced by the program is One TWO Three This is printed by the statements ListIterator myIterator = myList.listIterator(0); while (myIterator.hasNext()) { System.out.println(myIterator.next());Figures 3, 4, 5, and 6 show the progression of visualizations of the list after each operation. Not viewable in these figures are the detailed animation of the search through the list and the modification of links. For example, during the execution of the method call myList.set(myList.indexOf("Two"),"TWO"); a small arrow will trace the search through the linked list for the node with contents "Two" and, when it is found, will change the contents to "TWO." |
![]() |
![]() |
|
|
![]() |
|
|
![]() |
|
|
![]() |
![]() ![]() |
|
![]() |
5. JVALL Features
|
![]() |
![]() |
![]() ![]()
|
|
![]() |
![]() ![]()
|
|
![]() |
![]() ![]() |
|
![]() |
6. General Interactive
Linked List Controller |
![]() |
![]() |
|
|
![]() |
![]() The user can type into the value and position text boxes of this controller window to insert nodes into the specified position of the linked list. In standalone mode, a user has the option of opening text file, loading it into the linked list and continuing with the normal linked list operations such as insert, delete, and replace. Each time a button is clicked within the controller's window, JVALL receives a request from the controller and displays the animation accordingly. When the user requests an invalid operation such as inserting or deleting from a position that does not exist, JVALL will throw an appropriate exception. The controller will then catch that exception and report the problem, indicating to the user valid position choices. An example of this is shown in Figure 11. In Figure 11a, the user has selected position 4 to insert a new node. But the only valid positions for insertion would be 0, 1, 2, and 3. Figure 11b shows the resulting view. Here the appropriate message is reported for both the animation status and in the status textbox of the controller. These correspond because the controller program simply reports the status parameter that JVALL returns to it. |
![]() |
![]() |
![]() ![]() ![]() |
|
![]() |
|
|
![]() |
7. Educational Uses of
JVALL 7.1 Tutorials First, since any user-provided controller program can drive a JVALL visualization, the instructor can use the General Interactive Linked List Controller or design her own controller as appropriate for the instructional objectives. The second JVALL feature that supports in-class demonstrations is the ability to load into JVALL a previously saved list from a file. This enables the instructor to use examples on complex list structures without the overhead of spending class time building the list. In an on-line learning environment, JVALL can be controlled by tutorial software with appropriate visualizations occurring at specified places in the process. Such tutorials may or may not be interactive as the author of the controller determines. When the learning is not only on-line, but also distance learning, the use of the applet mode of JVALL is particularly helpful. 7.2 Active
Student Learning As an example of this, a Stack class has been built using the JVALL implementation of the Java LinkedList class and an interactive controller has been written to generate any possible operation on that class. A student might learn about the Stack class through JVALL visualization of the stack operations. Figure 12 shows a snapshot of this activity. |
![]() |
![]() |
![]() ![]() |
|
![]() |
![]() ![]() 7.3 Debugging
Student Programs |
![]() |
![]() |
8. Conclusions and Future
Work
According to these criteria, JVALL is a very effective tool for enhancing the learning of the algorithms and applications of linked lists. Future enhancements to JVALL include the implementation of additional linked list models such as doubly linked and header lists. In addition, this same process will be used to provide animated visualizations of other Java Collection classes such as ArrayList and TreeMap. |
![]() ![]() |
![]() |
9. Acknowledgments
|
![]() |
![]() |
10. References
[2] Stasko, J.T. TANGO: A framework and system for algorithm animation. IEEE Computer 23,9(1990), 27-39. [3] Naps, T.L. and Bressler, E. A multi-windowed environment for simultaneous visualization of related algorithms on the World Wide Web. SIGCSE Bulletin 30,1(1998), 277-281. [4] Pierson, W.C. and Rodger, S.H. Web-based animation of data structures using JAWAA. SIGCSE Bulletin 30,1(1998), 267-271. [5] Hundhausen, C.D., Douglas, S.A., and Stasko, J.T. A meta-study of algorithm visualization effectiveness. Journal of Visual Languages and Computing, to appear. [6] Haajanen, J., Pesonius, M., Sutinen, E., Tarhio, J., Teräsvirta, T., and Vanninen, P. Animation of user algorithms on the web. Proceedings of the 13th IEEE International Symposium on Visual Languages, IEEE Computer Society Press, 1997, 360-367. [7] Lattu, M., Tarhio, J., and Meisalo, V. How a visualization tool can be used--evaluating a tool in a research & development project. 12th Workshop of the Psychology of Programming Interest Group, April 2000. [8] Baker, R.S., Boilen, M., Goodrich, M.T., Tamassia, R., and Stivel, B.A. Testers and visualizers for teaching data structures. SIGCSE Bulletin 31,1(1999), 261-265. [9] Rößling, G., Schüler, M., and Freisleben, B. The ANIMAL algorithm animation tool. 5th Annual Conference on Innovation and Technology in Computer Science Education (ITiCSE), 2000, 37-40. [10] Crescenzi, P., Demetrescu, C., Finocchi, I., and Petreschi, R. Reversible Execution and Visualization of Programs with LEONARDO. Journal of Visual Languages and Computing, 11,2(2000),125-150. [11] Bergin, J., Brodlie, K., Goldweber, M., Jiménez-Peris, R., Khuri, S., Patiño-Martínez, M., McNally, M., Naps, T., Rodger, and Wilson, J. An overview of visualization: its use and design. Proceedings of the ACM SIGCSE/SIGCUE Conference on Integrating Technology into Computer Science Education, 1996, 192-200. [12] Cordova, J. A comparative evaluation of web-based algorithm visualization systems for computer science education, Journal of Computing in Small Colleges 14,3 (1999), 72-77. |
![]() |
![]() |
|
![]() |