[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[Honesty]
[Links]
[Syllabus]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
Misc:
[SamR]
[Java 1.4.2 API]
[EIJ]
[CS152 2000F]
[CS153 2004S]
Back to Dictionaries (1). On to Project Discussion.
Held: Monday, 8 November 2004
Summary: Today we consider a tree-based implementation of dictionaries, the binary search tree.
Related Pages:
Notes:
Overview:
middleelement.
smallerelements: everything less than the
middleelement.
largerelements: everything greater than the
middleelement.
public boolean binarySearch(BinarySearchable stuff,
Object findMe,
Comparator order)
{
if (stuff.isEmpty())
return false;
int compareVal = order.compare(findMe, stuff.middle());
if (compareVal == 0)
return true;
else if (compareVal < 0)
return binarySearch(stuff.smaller(), findMe, compare);
else ; if (compareVal > 0)
return binarySearch(stuff.larger(), findMe, compare);
} // binarySearch(BinarySearchable, Object, Comparator)
D
/ \
B F
/ \ / \
A C E G
Rebelsky
/ \
Ferguson Stone
/ \ / \
Chamberland Herman Shuman Walker
/ / \ \ \
Adelberg Gum Jepsen Silkin Wolf
\ / / \
Bishop French Hill MooreE
\ \
Kornelson MooreT
Dictionary with binary search
trees, we'll build a wrapper class. This class will permit us to
Comparator used to determine
large and small.
Back to Dictionaries (1). On to Project Discussion.
[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[Honesty]
[Links]
[Syllabus]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
Misc:
[SamR]
[Java 1.4.2 API]
[EIJ]
[CS152 2000F]
[CS153 2004S]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Wed Dec 8 10:37:24 2004.
The source to the document was last modified on Thu Aug 26 20:22:24 2004.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS152/2004F/Outlines/outline.38.html.
You may wish to
validate this document's HTML
;
;
Check with Bobby