Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use the program below to: Add a recursive method named getDepth() that returns a

ID: 3891837 • Letter: U

Question

Use the program below to:

Add a recursive method named getDepth() that returns an int that is the depth of the deepest node in the tree. Also add a recursive method named getSize() that returns the number of nodes in the tree. Add code to the main program to test your methods.

Write and test a copy constructor for the Binary Search Tree class. A copy constructor takes a reference to a BST and creates a copy. Note that you cannot just copy the root reference. You must go through the original tree and create copies of all the nodes. This is easiest to do with a recursive function that takes a parameter that is a Node. If the Node is null, return null, else return a new node that contains as data a copy of the original Node object, data, and the left and right references refer to copies of the left and right subtrees of the original Node. These copies are returned by recursive calls to the copy function. This is called making a deep copy. Test the constructor by creating a tree, making a copy of it, and then modifying the copy. Print out both the original tree and the copy to show they are actually different trees.

Explanation / Answer

Here are yout methods

And you test code

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote