Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Java, please create the following: Implement a binary search tree with all associated methods. You should create a class called BinarySearch TreeNode, which will

Using Java, please create the following:

image text in transcribed

Implement a binary search tree with all associated methods. You should create a class called BinarySearch TreeNode, which will implement the fundamental methods of a Binary search tree. Your binary search tree should be capable of performing the following operations: Constructor of your own design Getters/Setters for element, left, and right children Method to calculate size of the node and its descendants as a subtree* Method to calculate height of the node* Methods for Preorder and Postorder of all descendants *You may choose to store height and size in the nodes as metadata, but are required to have these methods compute height and size from scratch at each call. Do not write a method for these that just acts as a getter. You should also create a second class that will wrap around your entire Binary Search Tree, called BinarySearch Tree. BinarySearch Tree should act as a manager for your tree, and implement the following methods: Constructor that takes a node to be a root Getter/Setter for root node only Method to calculate size based on root Method to calculate height based on root Methods for preorder and postorder on root Method to calculate height based on a node that is passed in as a parameter* Method to calculate depth based on a node that is passed in as a parameter* Methods for preorder and postorder on a node that is passed in as a parameter* * Extremely important: These methods should fail if the node passed in is not part of the tree. This means you will need to search out the target node first! You will lose a lot of points if you fail to adhere to this requirement You must also write your own main class that adequately tests each of the above requirements. The design of this main class is entirely up to you, but I will use it to assess whether your methods work. Implement a binary search tree with all associated methods. You should create a class called BinarySearch TreeNode, which will implement the fundamental methods of a Binary search tree. Your binary search tree should be capable of performing the following operations: Constructor of your own design Getters/Setters for element, left, and right children Method to calculate size of the node and its descendants as a subtree* Method to calculate height of the node* Methods for Preorder and Postorder of all descendants *You may choose to store height and size in the nodes as metadata, but are required to have these methods compute height and size from scratch at each call. Do not write a method for these that just acts as a getter. You should also create a second class that will wrap around your entire Binary Search Tree, called BinarySearch Tree. BinarySearch Tree should act as a manager for your tree, and implement the following methods: Constructor that takes a node to be a root Getter/Setter for root node only Method to calculate size based on root Method to calculate height based on root Methods for preorder and postorder on root Method to calculate height based on a node that is passed in as a parameter* Method to calculate depth based on a node that is passed in as a parameter* Methods for preorder and postorder on a node that is passed in as a parameter* * Extremely important: These methods should fail if the node passed in is not part of the tree. This means you will need to search out the target node first! You will lose a lot of points if you fail to adhere to this requirement You must also write your own main class that adequately tests each of the above requirements. The design of this main class is entirely up to you, but I will use it to assess whether your methods work

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_2

Step: 3

blur-text-image_3

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

Building The Data Lakehouse

Authors: Bill Inmon ,Mary Levins ,Ranjeet Srivastava

1st Edition

1634629663, 978-1634629669

More Books

Students also viewed these Databases questions

Question

demonstrate the importance of induction training.

Answered: 1 week ago