rendered paste bodypackage PA4;public class BinaryTree { Node root; public BinaryTree() { this.setRoot(null); } public BinaryTree(Node root) { this.setRoot(root); } public Node getRoot() { return root; } public void setRoot(Node root) { this.root = root; } public Node search(Node presentNode, double value) { Node nodeFound = null; if (presentNode != null) { if (presentNode.getValue() > value) { this.search(presentNode.getLeft(), value); } else if (presentNode.getValue() < value) { this.search(presentNode.getRight(), value); } else { nodeFound = presentNode; } } return nodeFound; } public void insert(Node node) { if (this.getRoot() == null) { this.setRoot(node); } else { internalInsert(this.getRoot(), node); } } private static void internalInsert(Node presentNode, Node newNode) { if (presentNode.getValue() == newNode.getValue()) { return; } else if (newNode.getValue() < presentNode.getValue()) { if (presentNode.getLeft() == null) { presentNode.setLeft(newNode); } else { internalInsert(presentNode.getLeft(), newNode); } } else { if (presentNode.getRight() == null) { presentNode.setRight(newNode); } else { internalInsert(presentNode.getRight(), newNode); } } } // Calls one of the private traversal methods depending on argument public void traverse(String traverseType) { if (traverseType.equalsIgnoreCase("In-order")) { this.inOrderTraverse(this.getRoot()); } else if (traverseType.equalsIgnoreCase("Pre-order")) { this.preOrderTraverse(this.getRoot()); } else if (traverseType.equalsIgnoreCase("Post-order")) { this.postOrderTraverse(this.getRoot()); } else { System.out.print("Command not found"); } } private void inOrderTraverse(Node node) { if (node == null) { return; } else { inOrderTraverse(node.getLeft()); System.out.print(node.getIdentifier() + "\b"); inOrderTraverse(node.getRight()); } } private void preOrderTraverse(Node node) { if (node == null) { return; } else { System.out.print(node.getIdentifier() + "\b"); inOrderTraverse(node.getLeft()); inOrderTraverse(node.getRight()); } } private void postOrderTraverse(Node node) { if (node == null) { return; } else { inOrderTraverse(node.getLeft()); inOrderTraverse(node.getRight()); System.out.print(node.getIdentifier() + "\b"); } }}