1.求二叉树中节点个数
2.求二叉树叶子节点个数
3.求二叉树的深度
4.求二叉树第K层的节点个数
#include <stdio.h>
#include <stdlib.h>
#define ElementType char
typedef struct Node {
ElementType data;
struct Node *lchild;
struct Node *rchild;
}BinaryTree;
//创建二叉树节点
BinaryTree* CreateBinaryTree(data) {
BinaryTree* t = (BinaryTree*)malloc(sizeof(BinaryTree));
if (!t) {
printf("空间不足!\n");
return NULL;
}
t->lchild = NULL;
t->rchild = NULL;
t->data = data;
return t;
}
/*
求二叉树中节点个数
递归解法:
(1&#