Question
JAVA PLZ BinaryTreeMainProgram.java: public class BinaryTreeMainProgram { public static void main(String[] args) { MyBinaryTree myTree = new MyBinaryTree (); myTree.add(12); myTree.add(10); myTree.add(5); myTree.add(9); myTree.add(11); myTree.add(3);
JAVA PLZ
BinaryTreeMainProgram.java:
public class BinaryTreeMainProgram { public static void main(String[] args) { MyBinaryTree
System.out.println(); System.out.println("The tree looks like : "); myTree.printSideways();
// New Code Part 1 System.out.println("******* New Code Part 1 *************"); System.out.print("Does the tree contian 9? : "); System.out.println(myTree.contains(9) );
System.out.print("Does the tree contian 20? : "); System.out.println(myTree.contains(20) );
// New Code Part 2 System.out.println("******* New Code Part 2 *************"); System.out.print("The minimum value is ? : "); System.out.println(myTree.getMin() );
// New Code Part 3 System.out.println("******* New Code Part 3 *************"); System.out.print("Removing : "); myTree.remove(13); System.out.println(myTree); System.out.println("The tree looks like : "); myTree.printSideways();
// New Code Part 4 System.out.println("******* New Code Part 4 *************"); System.out.print("The size of the tree is : " + myTree.size() );
} }
MyBinaryTree.java:
import java.util.NoSuchElementException;
/**************************************************** * Main Class MyBinaryTree ****************************************************/
public class MyBinaryTree
/**************************************************** * Helper Class TreeNode * Note that this is a class inside the tree ****************************************************/ private class TreeNode
// Root of the Main tree private TreeNode
/***************************************************** * toString Method (recursive method) *****************************************************/ private String toString(TreeNode
private void printSideways(TreeNode
private TreeNode public boolean contains(E lookFor, TreeNode /***************************************************** * getMin Method (starter method) ***************************************************/ public E getMin() { // Need to implement this. System.err.println("NOT IMPLEMENTED"); return null; } /***************************************************** * remove Method (recursive method) ***************************************************/ public E getMin(TreeNode /***************************************************** * remove Method (starter method) ***************************************************/ public void remove(E lookFor) { // Need to implement this. System.err.println("NOT IMPLEMENTED"); } /***************************************************** * remove Method (recursive method) ***************************************************/ public void remove(E lookFor, TreeNode public int size(TreeNode
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started