Animations
A number of the more important or interesting algorithms covered in this course are available as animations using the AlgAE (Algorithm Animation Engine) system.
These allow you to view a picture of the data being manipulated while you “play” an algorithm like a DVD or DVR, forward or reverse, pausing, moving continuously or just a short hop at a time, much as if you were desk checking the algorithm.
1 Launching the Animations
Download the animation
Right-click on one of the links and select the “Save … as” option (the exact wording varies from one browser to another).
Launch the animation.
Each animation is packaged as a .jar
file. You will need a Java Runtime Environment (JRE) or Development Kit (JDK) version 11 or later, which you may well already have on your PC. If not, get it here. I recommend sticking with the LTS (Long Term Support) versions.
-
On Windows or MacOS, you should be able to launch the animation by double-clicking the
.jar
file or by opening it from the downloads bar of your browser. -
On Linux, or if double-clicking does not work, launch the animation by giving the command
java -jar
path-to-the-downloaded-jarfile
_Recent releases of Java appear to have broken backwards-compatibility with older like these demos. If the animation launches but does not activate the
Algorithm
menu, or if the picture seems to flicker badly,
2 Running the Animation
-
Use the Algorithm menu to select the desired algorithm.
(Tip: when creating data structures, keep them small. You will be stepping through the algorithms in fine detail.)
-
Use the “step” button to advance the algorithm and pause. Or use the “play” button to advance continuously. The “pause” button can be used to stop a running animation.
- If you find the display is too hopelessly tangled, you can use your mouse to drag the objects to more appropriate positions whenever you are paused within a running algorithm.
3 Available algorithms
These feature code from the textbook (Weiss) and/or from the lecture notes.
3.1 Sequences
- Array operations
- Vectors – implementation
- Linked lists (singly linked)
- Linked lists (doubly linked)
- Queues (linked list implementation)
- Stacks: RPN calculator
3.2 Trees
- Tree traversals
- Binary search trees
- Binary search tree iterators
- AVL tree (balanced binary search trees)
- Heaps
3.3 Hashing
The hashing demos use a deliberately awful hash function (length of the string) to make it easy to select inputs that will collide. This allows you to observe collision handling easily.
3.4 Graphs
(Right-click on the links and select “Save link as…” or the nearest thing offered by your browser to download.)