package sort;
public class Test55_2 {
public static boolean isBalance(BinayTreeNode bt) {
if (bt == null)
return true;
if (Math.abs(getdeepth(bt.left) - getdeepth(bt.right)) > 1)
return false;
return isBalance(bt.left) && isBalance(bt.right);
}
private static int getdeepth(BinayTreeNode left) {
// TODO Auto-generated method stub
if (left == null)
return 0;
return Math.max(getdeepth(left.left), getdeepth(left.right)) + 1;
}
}