Lab 3: Tree Traversal

Due Date and Submission Requirements


The goal of this lab is:


Directions

Consider a tree data structure that captures the structure of faculty at Montana State University.

Internal nodes just have a name value, and leaf nodes contain the name of the professor, their title, and their office location. Each node also contains the depth of the Node.
This tree is captured in FacultyTree.java, FacultyTreeDemo.java, and Node.java (linked below). You will download this code, and write the body for the following methods. You should not modify anything else, unless you want to modify the demo class to test your code.


1. Fill in the body for the public void printTree() method. This method will traverse the tree using depth-first and print out each Node (just the name) while matching the sample output:

root
-Depth1Node
--Depth2Node
---Depth3Node
---->LeafNode
---->LeafNode
---Depth3Node
---->LeafNode
--Depth2Node
...


2. Fill in the body for the public int getHeight() method. This method returns the height of the tree. Your solution for this method should use depth first or breadth first somewhere.

3. Fill in the body for the public void searchFor(String name). This method traverses the tree using breadth first and searches for a faculty member by name.
If the faculty member is found, it should print out their information. If they are not in the tree, it should print out "[name] was not found in the tree". See sample output

That is three methods in total.

Required Output

When you run your program, it should look exactly like output seen in in this screenshot .

Starting Code

Grading (10 points)

NOTE: If your code does not compile, correctness cannot be verified and you won’t receive any points for your code. Turn in code that compiles!