Question: Please write a java code to solve following question and explain if you can, it would be greatly appreciated! Part2: General Tree In this part,
Please write a java code to solve following question and explain if you can, it would be greatly appreciated!

Part2: General Tree In this part, you have been asked to create a simple ADT tree. A company asked you to create a tree like the following: As you can see you need the following: - a Worker.java class, that only have name and salary attributes, you should have a constructor for this class. - You need a Binary TREE ADT class to hold the tree. - The Tree elements can have no children or many children (0,1,2,3,) - A binary tree ADT needs the following - You need to also write a method to print the tree (nothing fancy!!) - You may do it in-order, preorder,... - Last part, create a main - create the workers with their name and salary - Add them to the tree similar to image, remember to use setLeft and setRight - Lastly use your print and print the tree Part 3: Analysis 1. What is the time complexity of adding new element to a binary tree? 2. What if we used general tree (0 to many children), what would be the time complexity of adding new element? Would the number of children have any effect on it? 3. What is the worst case for adding a new element to a general tree? 4. Is there a relationship with the height of a tree and time complexity
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
