package sort;
public class Test55 {
public static void main(String[] args) {
int deepth = 1;
BinayTreeNode root = new BinayTreeNode(1, null, null);
makeTree(root, deepth);
System.out.println(getDeepth(root));
}
public static int getDeepth(BinayTreeNode node) {
if (node == null)
return 0;
int left = getDeepth(node.left);
int right = getDeepth(node.right);
return left > right ? left + 1 : right + 1;
}
private static void makeTree(BinayTreeNode node, int deep) {
if (deep > 0) {
node.left = new BinayTreeNode(node.value * 2, null, null);
node.right = new BinayTreeNode(node.value * 2 + 1, null, null);
makeTree(node.left, deep - 1);
makeTree(node.right, deep - 1);
}
}
}