[Instructions] [Search] [Current] [News] [Syllabus] [Glance] [Links] [Handouts] [Project] [Outlines] [Labs] [Assignments] [Quizzes] [Exams] [Examples] [EIJ] [JPDS] [Tutorial] [API]
Back to Introduction to Trees. On to Lab: Traversing and Iterating Trees.
Held Tuesday, April 25, 2000
Overview
Today we continue our discussion of trees, developing an interface and beginning to investigate implementations.
Notes
http://chronicle.com/free/2000/04/2000042501t.htm
http://www.math.grin.edu/~rebelsky/CS152/Project/Phase5/
http://sigact.acm.org/genealogy/
Contents
Summary
Does it fly?
yes / \ no
/ \
Is it a bird? Does it swim?
yes / \ no ...
/ \
... Is it nocternal?
yes / \
/ ...
Bat
+
/ \
3 -
/ \
* 6
/ \
4 5
public interface Tree
{
/**
* Add another child to a vertex in the tree.
* Pre: The vertex (parent) is in the current tree.
* Post: The vertex (parent) has another child. The new child
* contains newThing.
* @exception Exception
* when the parent permits no more children
*/
public void add(Object newThing, Vertex parent)
throws Exception;
/**
* Get the root of the tree.
*/
public _______ getRoot();
/**
* Get the vertex that corresponds to an instance of
* a particular object.
* @exception Exception
* If it's not there.
*/
public Vertex find(Object findMe)
throws Exception;
}
public class Vertex {
} // class Vertex
find operation might be
better described in terms of more primitive operations, just as
find and member in lists are implemented
through the core list operations, car, cdr,
and empty.
public class TreeNode
implements Vertex
{
// +--------+----------------------------------------
// | Fields |
// +--------+
/** The contents of the current vertex. */
protected Object contents;
/** The children of the current vertex. */
protected SequencedList children;
// +-----------------+-------------------------------
// | Everything Else |
// +-----------------+
...
} // class TreeNode
public class NodeBasedTree
implements Tree
{
// +--------+----------------------------------------
// | Fields |
// +--------+
/** The root of the tree. */
protected TreeNode root;
/** The number of elmements in the tree. */
protected int size;
// +-----------------+-------------------------------
// | Everything Else |
// +-----------------+
...
} // class NodeBasedTree
Tuesday, 18 January 2000
Tuesday, 25 April 2000
Back to Introduction to Trees. On to Lab: Traversing and Iterating Trees.
[Instructions] [Search] [Current] [News] [Syllabus] [Glance] [Links] [Handouts] [Project] [Outlines] [Labs] [Assignments] [Quizzes] [Exams] [Examples] [EIJ] [JPDS] [Tutorial] [API]
Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
This page may be found at http://www.math.grin.edu/~rebelsky/Courses/CS152/2000S/Outlines/outline.46.html
Source text last modified Tue Apr 25 08:52:33 2000.
This page generated on Tue Apr 25 09:08:16 2000 by Siteweaver. Validate this page's HTML.
Contact our webmaster at rebelsky@grinnell.edu