Druk drzewa Java Binart
public void printTree(){
int height = maxHeight(root);
for(int i = 0;i < height;i++){
printLevel(root, i);
}
}
private void printLevel(Node node, int level){
if(node == null){
return;
}
if(level == 0){
System.out.println(node.value+" ");
}else{
printLevel(node.left, level - 1);
printLevel(node.right, level -1);
}
}
private int maxHeight(Node root){
if(root == null){
return 0;
}
return 1+Math.max(maxHeight(root.left), maxHeight(root.right));
}
Real Raven