Question: In your Lab 6 _ Driver dass, create a static tree instance and buld a simple tree of names that is similar in structure (
In your LabDriver dass, create a static tree instance and buld a simple tree of names that is similar in structure but not cantent to the followine tree. That is the tree contals is names. You must use vald names of your choice instead of the letters.
Include the following static methods in your LabDriver:
all Deacendants that takes a nodeposition as parameter and recursively displays all the descendants of that position.
Note how the children method returns an Iterable: you should use this to traverse through the list of children of a node and recursively display their children.
For example, using the node ramed above, the method display:
F G J K
Illustrate this method by displaying of the deicendants of the root node. lllustrate this method by dieplaying ait the descendants of the right child of the root node. You must use the right! method in this.
pathroroot that display the path from any given nodeposition to the coot of the tree.
Think of this as a position being traverged through the path to get from the position to the root and consider how we've traversed through a Inted list from the first to last.
For example, for the given tree, the following shows the path from the node upwards to the root:
Perkfrom to root
Illustrate this method by displayng the path from the leftmont node at the deepest level es node with above.
In your LabDriver, include the code to do the following:
Display the height of the tree.
Display the depth of the tree left child of the root node. You must use the left method in this.
Aemove the node at the leftmost position of the deepest level. E node above
Display the final size of the tree.
Display the output as shown below.
Sample Output
The descendants of A:
The descendants of C :
The path from H to root :
Tree Height:
Depth of left child of the root B :
Removed node with: H
Final tree size:
Submission
Submit your Lab zip file that includes all the following files Position java, Tren. ava. AbstractTree.java, BinaryTree.java, AbstractBinaryTree.java,
LinkedBinaryTree.java, LabDriver.java and any other files you use via Nexus.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
