Binary Tree - Java Pt. 2

Chris Chen
public class Driver {

public static void main(String[] args){

BinaryTree a = new BinaryTree("7");
BinaryTree l = new BinaryTree("4");
BinaryTree lr = new BinaryTree("5");
BinaryTree r = new BinaryTree("9");
BinaryTree rr = new BinaryTree("2");
BinaryTree lrl = new BinaryTree("0");

lrl.attachLeft("3");
lrl.attachRight("8");

rr.attachLeft("6");
rr.attachRight("1");

r.attachRightTree(rr);

lr.attachLeftTree(lrl);
l.attachRightTree(lr);

a.attachLeftTree(l);
a.attachRightTree(r);

System.out.println(a.count());
System.out.println(a.height());
System.out.println(a.find("6"));
System.out.println(a.find("41"));
System.out.println(a.max());
a.preorder();
a.inorder();
a.postorder();

BinaryTree b = new BinaryTree(a);
System.out.println(b.count());
System.out.println(b.height());
System.out.println(b.find("6"));
System.out.println(b.find("41"));
System.out.println(a.max());
b.preorder();
b.inorder();
b.postorder();

BinaryTree c = new BinaryTree("");
c.readFile("Test.txt");

c.preorder();
c.inorder();
c.postorder();

}

}

Published by Chris Chen

Chris is currently attending the University of California, Berkeley seeking an undergraduate's degree in Electrical Engineering Computer Science. He enjoys playing basketball, practicing kendo, hanging out w...  View profile

To comment, please sign in to your Yahoo! account, or sign up for a new account.