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. detailed comments will be much appreciated, thanks! # In the instructions,

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

detailed comments will be much appreciated, thanks!

image text in transcribed# 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

# The codes should include: Worker class, Method of binary tree, Method for visiting and printing the tree, Main class.

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

Relational Database Technology

Authors: Suad Alagic

1st Edition

354096276X, 978-3540962762

More Books

Students also viewed these Databases questions

Question

=+3 In what ways can an MNE improve or change its approach to IHRM?

Answered: 1 week ago