//利用 汇总 的方法求
//左子树第K层
//看K-1的左右孩子个数,即K的上一层左孩子,右孩子个数
import java.util.*;
public class Trees{
public static int calcKLevel(Node root, int K){ // 计算二叉树第K层的结点个数
if(root == null){
return 0;
}
if(K == 1){
return 1;// 第一层只有一个
}
int left = calcKLevel(root.left, K - 1);
int right = calcKLevel(root.right, K - 1);
int count = left + right;
return count;
}
}