Implementing a Binary Search Tree Map, Due Wednesday, 10/2
All of you are always identified by alpha, which is very frustrating for those of us who have no interest in memorizing which alpha corresponds to which midshipman. Let's fix the problem by making a Map implemented with a Binary Search Tree.
You'll write a class called BSTMap which will map alphas to names, organizing data in the tree by alphas (small ones to the left, big ones to the right), and have methods such that main methods like the one below will work:
public class MapMain {
public static void main(String[] args) {
BSTMap map = new BSTMap();
map.insert(222222,"Don Gately");
map.insert(111111,"Ender Wiggin");
map.insert(333333,"Kilgore Trout");
System.out.println(map.get(333333));
System.out.println(map.get(222222));
try {
System.out.println(map.get(444444));
} catch (IllegalArgumentException iae) {
System.out.println(iae.getMessage()); //Prints out that this alpha did
//not appear in the Map.
}
}
}
This class, when run, should print out:
taylor@albert:~/Test/BSTMap$ java MapMain Kilgore Trout Don Gately 444444 not in map
You'll use methods very similar to ones we've already written in class, you just have to turn it into a Map. Please submit it as BSTMap.