Lab 6 – Working with Trees (30pts)
Be sure to submit all questions and the two parts of this assignment by the due date. You may zip all of the files together to submit on blackboard.
Code Activities:
Part 1 - Tree Height (10 pts)
Add a method to the LinkedBinaryTree class that returns the height of a tree. Like many tree methods, this will require a fairly simple method in LinkedBinaryTree and another method in BTNode that does most of the work. First, check to see if the root is null. If it is, then the tree is obviously empty and return 0. If it is not null, return root.height().
Part 2 - Decision Tree (20 pts)
Create a decision tree for a topic of your choice. Examples: How to choose a college major? How to select a car? How to determine what to eat for dinner? You must have at least 14 questions that you could potentially ask the user. You will need to add a few missing methods to get your program to work correctly. Take a look at Figure 19.13 in relation to the String variables in BackPainExpert.java.
Please make sure the assignment is done in java and that Part 2 has 14 questions asked.
Lab 6 – Working with Trees (30pts) Be sure to submit all questions and the two parts of this assignment by the due date. You may zip all of the files together to submit on blackboard. Code Activities: Part 1 - Tree Height (10 pts) Add a method to the LinkedBinaryTree class that returns the height of a tree. Like many tree methods, this will require a fairly simple method in LinkedBinaryTree and another method in BTNode that does most of the work. First, check to see if the root is null. If it is, then the tree is obviously empty and return 0. If it is not null, return root.height(). Part 2 - Decision Tree (20 pts) Create a decision tree for a topic of your choice. Examples: How to choose a college major? How to select a car? How to determine what to eat for dinner? You must have at least 14 questions that you could potentially ask the user. You will need to add a few missing methods to get your program to work correctly. Take a look at Figure 19.13 in relation to the String variables in BackPainExpert.java.