This lab is quite different from others. You will not be writing any lines of code, and you will not be turning in any printouts. Instead, you will be required to solve a few puzzles and to demonstrate your success in person with one of the course TAs. (Don't worry - you will be writing plenty of code other weeks!)
The textbook discusses performing an Euler Tour on a tree as a unified, recursive framework for a variety of common tree traversals. Our goal in this lab is to make sure you get a very well grounded understanding of this general concept, and the various things you might accomplish by customizing the process.
Actually, to be specific, the book only discusses the concept of an Eulur Tour in the context of binary trees. The three common traversal orders are generaly known as "preorder," "inorder," and "postorder", depending on when you consider "visiting" a node, relative to its children. In this context, the Eulur tour can be implemented as:
EulerTour (Tree T, Position p) { // consider this the time when p is visited "on the left" if (T.isInternal(p)) EulerTour(T, T.leftChild(p)); // consider this the time when p is visited "from below" if (T.isInternal(p)) EulerTour(T, T.rightChild(p)); // consider this the time when p is visited "on the right" }
The same concept can be applied to general trees as well (though the concept of "inorder" is not quite well defined). In this context, the pseudocode might appear as:
EulerTour (Tree T, Position p) { // consider this the time when p is visited "on the left" Iterator children = T.children(p); while (children.hasNext()) { Position child = (Position) children.nextObject(); EulerTour(T, child); // if there are still more children to come, // consider this a time when p is visited "from below" } // consider this the time when p is visited "on the right" }
You will need to view this Applet using the appletviewer program rather than a browser. The reason is that the program will need to read input from the file system, and by default this is prohibited for security reasons, when running an Applet in a web browser.
The Applet can be viewed from a DOS window using the appletviewer program which is part of Sun's JDK. To do this from the department labs, open a DOS window from the "Programming (java) --> jdk (dos)" menu, and do the following:
DOSprompt> e: DOSprompt> cd prof_pub\mhg\comp271\labs\eulertour\ DOSprompt> appletviewer EulerTour.html
A sample screenshot of the Applet is given below (you may click to enlarge it).
To the right side of the screen, the Applet contains three columns of buttons which effect the behavior of the software during a tour. Essentially these buttons allow you to turn on or off features of the animation which get triggered with each such type of "visit" of a node.
You could choose to turn off some or all of the graphics, but for the
purpose of this lab, we recommend that you leave the graphics on.
A note about "refreshing" the graphics:
If the window is obscured while the Euler tour is being animated, the
obscured lines which may have previously been drawn are not
automatically refreshed when the window becomes visible again.
Please answer the following questions and turn in your answers to the TA.
"from the bottom"?
"on the right"?
Note: To get these, you can either use pauses (time consuming), look
at the last two pieces of output (easier), or answer the question on your own
without using the software (are you right?).
We are grateful to Min Wang, a former Loyola student, for developing the original version of this software as an independent project in 2000.