1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
|
int count(struct Node* n, int depthRemaining) {
if (depthRemaining < 0 || n == NULL) return 0;
return 1 + count(n->left, depthRemaining-1) + count(n->right, depthRemaining-1);
}
int main(void) {
//... (Baum erzeugen)
printf("%d\n", count(root, 1)); //3
printf("%d\n", count(root, 2)); //4
} |