前提
关于二叉树的创建有问题的可以参考下面这个文章
目录
目录
🍖二叉树结点个数
int Size(BinTree t)
{
assert(t);
if (t == NULL){
return 0;
}
else{
//左子树的个数+右子树的个数+根节点
return Size(t->leftChild) + Size(t->rightChild) + 1;
}
}
🍖先序遍历
//先序遍历
void BinTreeVLR(BinTree t)
{
assert(t);
if (t != NULL){
printf("%c", t->data);//先输出根结点
BinTreeVLR(t->leftChild);
BinTreeVLR(t->rightChild);
}
}
🍖中序遍历
//中序遍历
void BinTreeLVR(BinTre