Question: Problem 1: Write a class that implements a generic binary search tree including the methods add, contains and printInorder. (We will do this as a

Problem 1: Write a class that implements a generic binary search tree including the methods add, contains and printInorder. (We will do this as a group) Problem 2: Add a toString method to the class. This method returns a string of the form [e1, e2, , en] containing all of the elements in the tree in order. Problem 3: Add a method to the class that returns the number of leaves in the tree. Problem 4: Add a clone method to the class that returns a copy of the tree. Remember that we have three different ways of traversing a tree: preorder, inorder and postorder. Does it matter which one you use in this method? Problem 5: Add an equals method to the class. Two trees are equal if they include the same elements. The structure of the trees does not have to be the same.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!