Details of this Paper

Extends the Binary Tree




The SimpleTree class shown below extends the BinaryTree class that was given out as part of SampleCode#7 and SampleCode#8, and as part of SampleCode #10. You are to write four methods for the SimpleTree class shown below called findMin(), findMax(), removeMin() and removeMax().;The methods are already in the SimpleTree class, but they do not do anything yet. The findMin() and findMax() methods should return the smallest or largest node value (respectively) as determined by the compareTo() method. And the removeMin() and removeMax() methods should remove the smallest or largest node value (respectively).;Note that the BinaryTree class implements a Binary Search Tree.;SampleCode10:;Answer;public class SimpleTree extends BinaryTree;public SimpleTree();super();public SimpleTree(E element, SimpleTree left, SimpleTree right);root = createNewNode(element);root.left = (left == null)? null: left.getRoot();root.right = (right == null)? null: right.getRoot();public E findMin();// Your code goes here;public E findMax();// Your code goes here;public void removeMin();// Your code goes here;public void removeMax();// Your code goes here;public E getRootElement();return (root == null)? null: root.element;public SimpleTree getLeftNode();return getTreeNode(root.left);public SimpleTree getRightNode();return getTreeNode(root.right);private SimpleTree getTreeNode(TreeNode node);if (node == null) return null;return(new SimpleTree (node.element;getTreeNode(node.left),getTreeNode(node.right)))


Paper#67100 | Written in 18-Jul-2015

Price : $22