Final Exam Part 2 (Programming).
Final Exam Part 2 (Programming).
The AVLTree.java file contains the minimum amount of code for this problem. You will
see there is a section designated as STUDENT CODE. This is where your
method/methods should be placed. DO NOT MODIFY ANY OTHER CODE OR THE
METHOD HEADER OF OUTER. You may add any additional private utility methods
you see fit.
The OuterTest.java file contains the test code that will test different trees and produce
output indicating whether you pass or fail a test. There are 10 tests. Each passed test
is worth 10 points for a total of 100 points. Simply returning the result based on the test
tree given will not count as a solution. I will look at the code to ensure traversal of the
tree is being performed to get the solution.
The Problem
You must implement the method outer in AVLTree.java which returns a HashSet of the
values, not the nodes, which are the outer elements of the tree. The outer elements of
a tree are those which are the root, extreme left, extreme right, and those which can be
reached from the bottom and are not "blocked". A "blocked" element is one that has
both a left and right child. An example tree is the following.
In the above tree, the nodes which are red triangles are considered outer nodes. Node
a is the root node. Nodes b, d, and h are the extreme left nodes. Nodes c and g are
the extreme right nodes. Nodes i, e, j, k, and l are not blocked from the bottom. Only 1
node is not considered an outer node because it is blocked from the bottom. Your
implementation should return a hashset of the elements contained in nodes a, b, d, h, i,
e, j, k, l, g, and c.
Submission
Once you have a solution, submit only your completed AVLTree.java file with your
implementation of the outer method.
Test Trees
In addition to the OuterTest.java file, here are images of each of the trees in
OuterTest.java except for the empty tree which should just return an empty HashSet.
Single Node
Balance Tree 1
Balance Tree 2
Balance Tree 3
Balance Tree 4
Balance Tree 5
Balance Tree 6
Balance Tree 7