Question: Please read all the istructions!!! MyTree.java is provided and I can only edit Remove method, printReverse method and display method of MyTree.java. I cannot edit

Please read all the istructions!!! MyTree.java is provided and I can only edit Remove method, printReverse method and display method of MyTree.java. 

I cannot edit anything else. I have highlighted what can be edited.

Implement remove and printReverse method Implement display method to display the tree structure

Given: MyTree.java & TreeNode.java

public class MyTree{

private TreeNode root; public MyTree(){ root=null; } public void remove(int data){ //implement this method to remove a node with the same data value } public void printReverse(){ //implement this method to print data in descending order } public void display(){ //implement to display the tree structure } public boolean isEmpty(){ return root==null;} public int size(){ return sizeHelper(root); } private int sizeHelper(TreeNode node){ if(node==null) return 0; else return 1+sizeHelper(node.getLeft())+sizeHelper(node.getRight()); } public boolean search(int data){ return searchHelper(root, data); } private boolean searchHelper(TreeNode node, int data){ if(node==null) return false; if(node.getData()==data) return true; else if(node.getData()

public class TreeNode implements Comparable{

private int data; private TreeNode left; private TreeNode right;

public TreeNode(int data){ this.data=data; left=right=null; }

public int getData(){ return data; } public TreeNode getLeft(){ return left; } public TreeNode getRight(){ return right; } public void setData(int data){ this.data = data; } public void setLeft(TreeNode left){ this.left = left; } public void setRight(TreeNode right){ this.right = right; } public int compareTo(TreeNode node){ return data-node.getData(); } }

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!