Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Algorithms question in Java : Do not use built-in functions or classes of JAVA. This question is designed similarly to a job interview. First, we

Algorithms question in Java: Do not use built-in functions or classes of JAVA.

This question is designed similarly to a job interview. First, we will introduce a problem. You then

need to apply critical thinking, design a solution, evaluate the solution (Big-O), then improve it if needed.

Lastly, you will implement your solution.

detailed comments will be much appreciated, thanks!

# In the instructions, there is a mistake. The methods setLeft, and setRight have 2 input arguments each (of Worker type). In the instructions, it is stated that they have one input argument p. For example, for the setLeft method, 2 input arguments of the Worker type are required, one as the root and one as the left child.

# The signature of the methods described in the tables of instructions includes the word "static". Implementing the methods as static is not required, and only the name of the method needs to be the exact same.

# For the SetLeft method, 2 input arguments of the Worker type are required. Just be careful that the root here does not refer to the root of the tree and rather the root of the sub-tree you are adding the child to.

# The idea is that you should have a general tree with many children but for simplicity of it, we are using only binary tree. setRight, setLeft methods Do not need to return anything. For size, it should return the number of nodes in the tree --- n

image text in transcribed

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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago