Assignment 2
CS 146
due October 9, 2002
100 points

Redo Assignment 1, but using the class A2 to test your program, using a class AVL that implements an AVL tree to index your student file class, and making the other changes below. Your AVL tree should implement the interface MiniMap. The class A2 and the interface MiniMap are available from the class web site.

Since the AVL tree is really implementing a map in this application, you may assume that its entries are pairs consisting of a key that is a Comparable, and an entry that is an Object. Your AVL implementation should make no further assumptions about the classes of the elements that the AVL tree is to contain.

The MiniMap interface is similar to Map, except that it contains only the methods isEmpty(), put, get, containsKey, and values. These methods differ from the corresponding methods of Map only as follows:

  • all key values are of formal parameter type Comparable
  • the put method should reject an attempted insertion of a second entry with the same key. It should return true if the insertion is performed, and false otherwise.
  • the values method is to return a List of the values in the MiniMap, sorted in the order of their keys. The StudentRecord class should have public accessor methods getName and getIdNumber.

    The method traverse of StudentFile should print the sequence of student records sorted by id number. The StudentFile class should also have the following methods

  • a method traverseLevels that prints the sequence of student records in the order that they appear in a level order traversal of the underlying AVL tree
  • a method containsStudent in addition to getStudentRecord
  • a method sortByName that returns a List of student records sorted by name
  • a method sortByGPA that returns a List of student records sorted by GPA The last two methods needn't sort as efficiently as the sort by student id number. You may use the method at the bottom of p.515 as a guide. You needn't credit this method.

    You may use the definitions of the text, of its associated web site, or of my version of Assignment 1 provided that you give proper credit.

    As always, you may define additional classes or methods if you find them helpful.

    You should show the results of testing with the test file A2.java, which is provided on the class web site. You needn't turn in this file unless you change it.