Fall Semester 2005: September 8, 2005 - December 12, 2005
Out on:
October 21, 2005
Due by:
October 27, 2005 by 5:59 pm for full credit (11:59 pm for 10% off, hard deadline)
Collaboration:
Pairs
Grading:
Packaging 10%, Style 10%, Performance 10%, Design 20%, Functionality 50%
The seventh assignment for
600.226: Data Structures
deals mostly with sets of one sort or another.
There are some "written" problems as well, to be answered in the
README file.
Note that each pair hands in one assignment only.
Be sure to include the relevant information (who is in the pair!)
in your README file! Both of you are getting the
same score for the assignment.
Here are the necessary interfaces and exception classes: sets.tar.gz As usual, you are not allowed to change the interfaces in any way! If you think something is wrong, email the discussion list and check.
Your first task is to write two implementations of the
Set interface provided above.
You are free to use arrays, your own lists, or Java's
ArrayList for one or both, up to you.
The first implementation, SimpleSet, should
be as simple as you can make it, no fancy tricks.
The second implementation, FancySet, should
incorporate the "move-to-front" heuristic to anticipate
access patterns better.
As usual, please provide a toString() method to
return a String representation of the set.
Also, write a short program to test your two implementations
and to compare their performance on various kinds of access
patterns; the details are up to you, but the program should
be called TestSet.
Feel free to "borrow" ideas from Assignment 2 where we provided
you with some code that tested and compared the performance of
various sorting algorithms; you're not sorting now, but the code
there shows how to "time" things.
Please comment on your results in your README
file.
Your second task is to write two implementations of the
OrderedSet interface provided above.
Once again you are free to use arrays, your own lists or
trees, or Java's ArrayList for one or both,
up to you.
The first implementation, SimpleOrderedSet,
should maintain an array or list in sorted order; once
again you should aim for simplicity and avoid fancy tricks.
The second implementation, HeapOrderedSet,
should implement the set using a heap data structure.
Once again, please please provide a toString()
method to return a String representation of the
set.
You should also write another test program,
TestOrderedSet
to test and compare the performance of your two implementations.
Please comment on your results in your README
file.
Design and document an interface PriorityQueue
that does not use "set semantics," i.e. if
you insert the same element three times it also "comes out"
three times.
Try to make your interface "fit in" with the Queue
interface we used before; should PriorityQueue be
"related" in any way to the previous Queue
interfaces? Would you prefer to change the "old" interfaces
in some way to accomodate PriorityQueue?
Explain your reasoning.
You don't have to implement the interface!
Do some "research" to figure out what properties the abstract
data type Bag has; it's related to Set
in some ways, but it's different in others.
Design and document an interface Bag for this
abstract data type. Should the Bag interface
be "related" in any way to the Set interface?
Explain your reasoning.
You don't have to implement the interface!
Please turn in a
gzip
compressed
tarball
of your assignment (the extension should be .tar.gz).
The tarball should uncompress into a directory
cs226-assignment-7-login1-login2
with login1 and login2
replaced by your Unix login names;
uncompressing should not create any other files
in the current directory.
The tarball should contain no derived files whatsoever
(i.e. no .class files, no .html files, etc.),
but allow building all derived files.
Include a README file that briefly explains what your
programs do and contains any other notes you want us to check out
before grading (and of course your answers to "written" problems).
For reference, here is a short explanation of the grading criteria.
Packaging refers to the proper organization of the
stuff you hand in, following the guidelines for Deliverables above.
Style refers to Java programming style, including
things like consistent indentation, appropriate identifiers,
useful comments, suitable javadoc documentation, etc.
Simple, clean, readable code is what you should be aiming for.
Performance refers to how fast your program can
produce the required results compared to other submissions.
Design refers to proper modularization and the
proper choice of algorithms and data structures.
Functionality refers to your programs being
able to do what they should according to the specification
given above; if the specification is ambiguous and you had
to make a certain choice, defend that choice in your
README file.
If your programs cannot be built you will get no points whatsoever.
If your programs cannot be built without warnings using
javac -Xlint
we will take off 10% (except if you document a very good reason).
If your programs fail miserably even once,
i.e. terminate with an exception of any kind,
we will take off 10%.
Books on data structures often come with lots of pictures that
illustrate how a certain data structure is "maintained" as certain
operations are performed.
Add code to your implementation of
HeapOrderedSet
that produces DOT output illustrating how the heap data structure
evolves as operations are performed on it; can you illustrate
the "bubble-up" and "bubble-down" processes as well as just
the final result of an insert() call?
Note that we won't give you extra points for this, but we'll give
you extra kudos. :-)