To be done in Java
We'll agree, as a class, on a List ADT, which will be
published on the Moodle as a Java interface
.
The ADT will include not only basic operations for construction
and querying, but a sort()
method and a
toString()
method.
Develop several different classes implementing this List ADT, using different internal representations:
Each student is expected to implement at least two of these, and I'd like each one to be implemented by at least two students. We'll discuss who's doing which in class or on Moodle.
Each implementing class should implement all the operations of the
interface, including sort
. Use the same sorting
algorithm, e.g. insertion-sort, for all implementing
classes. Do not use Java library sort methods; write your own.
Now suppose the sort
method hadn't been part
of the ADT, and therefore hadn't been supplied by the
implementers. Develop a sortFromOutside
method (in
another class) that takes in a List and,
without knowing which implementation it is,
sorts it by using only the (non-sort
) operations in
the ADT. I should be able to plug in an instance of any other
student's implementation and have your sortFromOutside
method sort it correctly.
Discuss the pros and cons of the various implementations. What kinds of problems would be easier to do in one implementation than another?