Need help with your Discussion

Get a timely done, PLAGIARISM-FREE paper
from our highly-qualified writers!

glass
pen
clip
papers
heaphones

North Lake College Binary Search Trees Java Coding Task

North Lake College Binary Search Trees Java Coding Task

North Lake College Binary Search Trees Java Coding Task

Description

Lab Assignment 25 (Binary Search Trees)

1.Write a Java project named Lab25A that will create our own tree node class and use it to build a binary search tree.

Create a secondary class named TreeItem with the following:

i.3 instance variables:

1.An integer value

2.Two TreeItem variables: left and right

ii.A constructor that receives an integer parameter. It should fill the integer instance variables and set the TreeItem variables to null.

iii.An int method that returns the value of the integer instance variable

iv.A String method named toString that returns a string with the integer instance variable (and a label).

Create another new class named BinarySearchTree with the following:

i.An instance variable named root (data type TreeItem)

ii.A constructor with no parameters that sets root equal to null

iii.A boolean method that

1.Receives one integer parameter

2.Inserts the integer parameter value in the tree

3.Use the “Inserting an Element to a Binary Tree” code in the PowerPoint notes to guide you.

4.Remember that our tree node data type is called TreeItem, not TreeNode, so you’ll need to change a few things

iv.A boolean method that

1.Receives one integer parameter and the TreeItem root

2.Searches for that value in the tree

3.Returns a true if it is found and false otherwise

4.Use the “Searching an Element in a Binary Search Tree” code in the PowerPoint as a guide.

v.A void method that

1.Uses the inorder algorithm to look at every node in our tree

2.It should print the value of all nodes and how many children they have. (They will have 0-2 children depending on whether left or right are null.)

3.If you go to the “BST Class” slide in the PowerPoint and click on the green box, it will show you code for BST. You can look at the 2 inorder methods there to get an idea of how to do this.

Back in the main method of the main class:

i.Create a new BinarySearchTree object

ii.Read a set of values from the text file (Lab25A.txt) and use the tree’s insertion method to place them in the tree

iii.Ask the user for an integer and call the tree’s searching method to see if it is in the tree.

iv.Call the tree’s void method to print all the node values and number of children.

You will also need to create a diagram in PowerPoint, Word or some other program to show what your tree will look like based on the values inserted and the order they were added. Name this file Lab25A_Diagram.

2.Write a Java project named Lab25B that will create a BinarySearchTree tree of string values and use the methods to fill and print it.

Make TreeItem and BinarySearchTree classes and copy the code from Lab25A into them

i.In the TreeItem class change the int instance variable to be a String variable and make any changes necessary to the methods to handle this new data type.

In the BinarySearchTree class

i.Add a new int instance variable named size and set it = 0.

ii.Increase size by 1 every time you insert a new node.

iii.Go to the “BST Class” slide in the PowerPoint and click on the green box see the code for code for BST.

iv.Copy all of the inorder, preorder and postorder methods into your BinarySearchTree class. (Don’t copy the @Override lines above them.)

v.Adapt the methods to work with the TreeItem class instead of TreeNode

vi.Add an int method with no parameters that returns size.

In the main method:

i.Create a new BinarySearchTree tree

ii.Read integer values from the text file (Lab25B.txt)

iii.Add each value to the tree

iv.After adding all the values, print the size of the tree (using the new function)

v.Print the tree inorder, preorder & postorder. Make sure to state which order you are printing for each one.

You will also need to create a diagram to show what your tree will look like based on the values inserted and the order they were added. 

Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."

Order Solution Now

Our Service Charter


1. Professional & Expert Writers: Eminence Papers only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed of papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided by Eminence Papers are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. Eminence Papers are known for the timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit in all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At Eminence Papers, we have put in place a team of experts who answer all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.

We Can Write It for You! Enjoy 20% OFF on This Order. Use Code SAVE20

Stuck with your Assignment?

Enjoy 20% OFF Today
Use code SAVE20