Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Help on Reconstruction of Binary Tree

807607Nov 6 2006 — edited Nov 6 2006
I 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");
}

}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 4 2006
Added on Nov 6 2006
4 comments
93 views