Help on Reconstruction of Binary Tree
807607Nov 6 2006 — edited Nov 6 2006I have everything expect the reconstruct method and main method. Could someone help me create the reconstruct and main method?
package binarytree;
public class BinaryTree {
public BinaryTree(Object value, BinaryTree left, BinaryTree right){
info = value;
this.left = left;
this.right = right;
}
public Object getinfo(){
return info;
}
public BinaryTree getleft(){
return left;
}
public BinaryTree getright(){
return right;
}
private Object info;
private BinaryTree left, right;
static int height (BinaryTree node){
if (node != null){
return(int)(1+Math.max(height(node.getleft()), height(node.getright())));
}
return 0;
}
public static void traverseIn(BinaryTree node){
if (node == null) return;
traverseIn(node.getleft());
System.out.println(node.getinfo());
traverseIn(node.getright());
}
public static void traversePre(BinaryTree node){
if (node == null) return;
traversePre(node.getleft());
traversePre(node.getright());
System.out.println(node.getinfo());
}
public static void main(String[] args) {
//traverseIn = ("3 1 7 5 0 4 8 2 9 6");
//traversePre = ("0 1 3 5 7 2 4 8 6 9");
}
}