HW 3 - Note, this HW has 2 Parts


SETUP

Note that in this assignment, you will have to use the eclipse IDE. To start:



Part 1 - using an array-implemented tree to predict this year's Major League Baseball Playoffs.

In class we mentioned how a full binary tree can be managed efficiently using an array rather than node objects. That's what we'll do in this part. In the Major League Baseball playoff system, 8 teams compete for one World Series Championship title. We can think of such a playoff as a bracket. A bracket for such a tournament could logically be managed by a full tree data structure. Examine the following 3 files:

The BaseballPlayoffsFrame class has a main method that simply opens up a GUI, loads your tree with data concerning the 8 teams in the playoffs, and handles user input. The GUI has two buttons, which each time you press them they should produce random results weighted by team records for all playoff games. It will ask the tree managing class to perform this operation, sometimes asking it to perform this task, one doing it recursively, and one iteratively.

To do this, you will manipulate the tree, which stores all of its data in an array similar to the technique we discussed in lecture. I have defined the initTeams method, which takes an array of BaseballTeams, and places its contents into our tree-array, putting them into the indicices representing the tree leaves. All parent nodes, including the root, start out storing null, the reason is we don't know who's going to win the playoffs yet, only the teams entering, and based on the order they are given, who each team's opponent will be in the first round. You will have to write code that fills in the playoffs bracket with results.

YOUR TWO METHODS, BOTH IN THE PlayoffsManager CLASS:

HINT: Remember how we talked about pre, in, and post order traversal in a tree and the differences between them. Note that post order traversal means that parent node data is processed after its children's node data is processed. This seems a natural fit for the recursive portion of this problem, since we can't compute the playoff winner until we know who has won in the previous rounds.


Part 2 - PresidentBinarySearchTree

In this HW we are going to use a Binary Search Tree (BST) to keep President objects sorted so that we may access them efficiently. In fact, Binary Search Trees are only useful if their contents are sorted. We will use the President number as the criteria for sorting our objects.

Examine the following files:

Go through the code of these classes and read the documentation. The PresidentTreeFrame has a main method. That application will render your PresidentBinarySearchTree. You will define methods for adding, removing, and getting information about the nodes.

YOUR FOUR METHODS, ALL INSIDE THE PresidentBinarySearchTree CLASS:




Handin Instructions



Grading

All assignment will be graded purely based on program performance. Submissions that do not compile will receive 0 points. Submissions that never produce correct results will receive 0 points. The TAs will test your submissions using various input, and grades will be awarded depending on how often your code produces the correct results.




SUNYSB CSWeb page created and maintained
by Richard McKenna