To create a node for a binary search tree (BTNode, ) and to create a binary search tree of comparable objects (Tree BTNode BTNode -data:E -left: BTNode -right: BTNode +BTNode (newData:E, newLeft: BTNode, newRight: BTNode) +getData():E +getLeft():BTNode +getRight():BTNode +getRightMostData():E +inOrderPrint():void +removeRightmost(): BTNode +setData(newData:E):void +setLeft(newleft: BTNode):void +setRight(newRight: BTNode):void needed for remove needed for remove Tree for Lab 7 Tree -root: 8TNode - numltems:int +Tree() +add(element:E):void +remove(element:E):boolean + remove +size():int + printTree():void Solution //BTNode.java public class BTNode { private E data; private BTNode left; private BTNode right; public BTNode(E newData, BTNode newLeft, BTNode newRight) { data = newData; left = newLeft; right = newRight; }//end constructor /** * Returns the data * @return The data */ public E getData() { return data; }//end getData /** * Returns the left link * @return the left link */ public BTNode getLeft() { return left; }//end getLeft /** * Returns the right link * @return the right link */ public BTNode getRight() { return right; }//end getRight /** * Prints the tree in order from left to right. */ public void inOrderPrint() { if (left != null){ left.inOrderPrint(); }//end left System.out.println(data); if(right != null){ right.inOrderPrint(); }//end right }//end inOrderPrint /** * Sets the data in the node * @param newData The new data to be passed */ public void setData(E newData) { data = newData; }//end setData /** * Sets a new link to left * @param newLeft the new link to go left */ public void setLeft(BTNode newLeft) { left = newLeft; }//end setLeft /** * Sets a new link to the right * @param newRight the new link to the right */ public void setRight(BTNode newRight) { right = newRight; }//end setRight public E getRightMostData() { if(right == null){ return data; } else { return right.getRightMostData(); }//end right == null if-else }//end getRightMostData public BTNode removeRightmost() { if (right == null){ return left; } else { right = right.removeRightmost(); return this; }//end if right == null if=-else }//end removeRightMost }//end BTNode ===================================================================== == //Tree.java public class Tree> { private BTNode root; private int numItems; /** * No-arg constructor */ public Tree() { root = null; numItems = 0; }//end constructor public void add(E element) { if (root == null) { root = new BTNode(element, null, null); }else{ BTNode cursor = root; boolean done = false; while(!done){ if (element.compareTo(cursor.getData()) <= 0){//cursor.getData().compareTo(element) > 0){ if (cursor.getLeft() == null) { cursor.setLeft(new BTNode(element,null,null)); done = true; } else { cursor = cursor.getLeft(); } //end left is null if-else }else{ if(cursor.getRight() == null){ cursor.setRight(new BTNode(element, null, null)); done = true; }else{ cursor = cursor.getRight(); }//end cursor.getRight if-else }/.