Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me with the following program in Java. Thank you! Implement a binary search tree with all associated methods. You should create a class

Please help me with the following program in Java.

Thank you!

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. Be thorough. A grossly inadequate tester class will impact your grade

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

Databases Illuminated

Authors: Catherine Ricardo

2nd Edition

1449606008, 978-1449606008

More Books

Students also viewed these Databases questions

Question

Prove Theorem 3.3(c). (A + B)C = AC + BC

Answered: 1 week ago