【发布时间】:2022-01-01 12:00:27
【问题描述】:
代码引用了一个基本的树数据结构(节点)。
public int countLeaf2(Node <T> tree) {
if (tree.children.isEmpty() != true) {
for (int i=0; i<tree.children.size(); i++) {
countLeaf2(tree.children.get(i));
}
}
if (tree.children.size() == 2) {
count++;
}
return count;
}
【问题讨论】: