[Instructions] [Search] [Current] [Syllabus] [Links] [Handouts] [Outlines] [Labs] [More Labs] [Assignments] [Quizzes] [Exams] [Examples] [Book] [Tutorial] [API]
Back to The Design of Lists. On to Project Discussion.
Held Monday, October 25, 1999
Overview
Notes
Contents
Handouts
Summary
equals
for lessEqual, as in
protected int partition(int lb, int ub, Comparator compare)
throws IncomparableException
{
Object pivot = this.get(lb); // X: A to get
int first = lb;
int last = ub;
while (first < last) {
while ( (compare.lessThan(pivot, get(last)))
&& (first < last) ) {
last--;
} // while there are big elements on the right
while ( compare.equals(get(first), pivot)
&& (first < last) ) {
first++;
} // while there are small elements on the left
if (compare.lessThan(get(first),get(last) {
swap(first,last);
}
} // while
this.swap(lb,first);
return first;
} // partition
objects[i] rather
than get(i). Let's brainstorm reasons to prefer
the second over the first.
Tuesday, 10 August 1999
Monday, 25 October 1999
Back to The Design of Lists. On to Project Discussion.
[Instructions] [Search] [Current] [Syllabus] [Links] [Handouts] [Outlines] [Labs] [More Labs] [Assignments] [Quizzes] [Exams] [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/99F/Outlines/outline.31.html
Source text last modified Mon Oct 25 09:46:24 1999.
This page generated on Mon Oct 25 09:48:18 1999 by Siteweaver. Validate this page's HTML.
Contact our webmaster at rebelsky@grinnell.edu