[Instructions] [Search] [Current] [Syllabus] [Links] [Handouts] [Outlines] [Labs] [More Labs] [Assignments] [Quizzes] [Examples] [Book] [Tutorial] [API]
Back to Linear Structures for Solving Puzzles. On to Hash Tables.
Held Monday, April 19
Summary
Contents
Notes
Some of this information was covered in our lab on vectors.
Pair object that joins a
key and value.
public interface BinarySearchable
extends Collection
{
/**
* Get the ``middle'' element in the collection.
* Pre: The collection is nonempty.
* Post: Returns some designated element in the collection.
*/
public Object middle();
/**
* Get elements in the collection that are smaller than the
* middle element.
* Pre: The collection is nonempty.
* Pre: The collection has not been modified since the last call
* to middle.
* Post: Returns the smaller elements.
*/
public BinarySearchable smaller();
/**
* Get elements in the collection that are larger than the
* middle element.
* Pre: The collection is nonempty.
* Pre: The collection has not been modified since the last call
* to middle.
* Post: Returns the larger elements.
*/
public BinarySearchable larger();
/**
* Determine if the collection is empty.
*/
public boolean empty();
} // BinarySearchable
public class BinarySearchNode
{
/** The contents of this node. */
Object contents;
/** A linked structure of things smaller than this node. */
BinarySearchNode smaller;
/** A linked structure of things larger than this node. */
BinarySearchNode larger;
} // class BinarySearchNode
D
/ \
B F
/ \ / \
A C E G
Rebelsky
/ \
Ferguson Walker
/ \ / \
Adelberg Herman Stone Wolf
/ \
Flynt Jepsen
BinarySearchable, we'll build
a wrapper class. This class will permit us to
Comparator used to determine
large and small.
public class SearchTree
implements BinarySearchable
{
/** The contents of the tree. Set to null for empty trees. */
BinarySearchNode tree;
/** The comparator used to determine large/small. */
Comparator compare;
...
} // class SearchTree
History
Back to Linear Structures for Solving Puzzles. On to Hash Tables.
[Instructions] [Search] [Current] [Syllabus] [Links] [Handouts] [Outlines] [Labs] [More Labs] [Assignments] [Quizzes] [Examples] [Book] [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/99S/Outlines/outline.41.html
Source text last modified Mon Apr 26 09:19:22 1999.
This page generated on Mon Apr 26 10:22:31 1999 by SiteWeaver. Validate this page's HTML.
Contact our webmaster at rebelsky@math.grin.edu